A fundamental concept in `net/http` servers is *handlers*. A handler is an object implementing the `http.Handler` interface. A common way to write a handler is by using the `http.HandlerFunc` adapter on functions with the appropriate signature.
(w http.ResponseWriter, req *http.Request)
| 13 | // a handler is by using the `http.HandlerFunc` adapter |
| 14 | // on functions with the appropriate signature. |
| 15 | func hello(w http.ResponseWriter, req *http.Request) { |
| 16 | |
| 17 | // Functions serving as handlers take a |
| 18 | // `http.ResponseWriter` and a `http.Request` as |
| 19 | // arguments. The response writer is used to fill in the |
| 20 | // HTTP response. Here our simple response is just |
| 21 | // "hello\n". |
| 22 | fmt.Fprintf(w, "hello\n") |
| 23 | } |
| 24 | |
| 25 | func headers(w http.ResponseWriter, req *http.Request) { |
| 26 |
nothing calls this directly
no outgoing calls
no test coverage detected