Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableResponseCompression ¶
func DisableResponseCompression(w http.ResponseWriter)
DisableResponseCompression disables response compression on w.
The function must be called before the first w.Write* call.
func EnableCORS ¶
func EnableCORS(w http.ResponseWriter, _ *http.Request)
EnableCORS enables https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS on the response.
func Errorf ¶
func Errorf(w http.ResponseWriter, format string, args ...interface{})
Errorf writes formatted error message to w and to logger.
func Serve ¶
func Serve(addr string, rh RequestHandler)
Serve starts an http server on the given addr with the given rh.
By default all the responses are transparently compressed, since Google charges a lot for the egress traffic. The compression may be disabled by calling DisableResponseCompression before writing the first byte to w.
The compression is also disabled if -http.disableResponseCompression flag is set.
Types ¶
type RequestHandler ¶
type RequestHandler func(w http.ResponseWriter, r *http.Request) bool
RequestHandler must serve the given request r and write response to w.
RequestHandler must return true if the request has been served (successfully or not).
RequestHandler must return false if it cannot serve the given request. In such cases the caller must serve the request.