MCPcopy Create free account
hub / github.com/mmcgrana/gobyexample / hello

Function hello

examples/http-server/http-server.go:15–23  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

13// a handler is by using the `http.HandlerFunc` adapter
14// on functions with the appropriate signature.
15func 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
25func headers(w http.ResponseWriter, req *http.Request) {
26

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected