What function starts the default http server?
func ListenAndServer(addr string, handler Handler) error
Write a simple handler?
f := func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf("Hello, world!\n")
h := http.HandlerFunc(f)
}What settings help with a client that’s slow to send it request to the server?
http.Server {
ReadTimeout time.Duration
}What would with a slow server handler?
Wrap it with the http.TimeoutHandler
http.TimeoutHandler(h http.Handler, dt time.Duration, msg string) http.Handler
What does net/http provide to deal with multiple handlers?
The HTTP request multiplexer http.ServeMux. The multiplexer is itself a http.Handler.
mux := http.NewServeMux()
mux.HandleFunc("/1", handleOne)
mux.HandleFunc("/2", handleTwo)