Go module for serving multiple methods on a single HTTP path.
The Endpoint
struct is an implementation of the http.Handler
interface. Once an endpoint has been created, it can be served
using http.Handle()
, or any other function that accepts the
http.Handler
interface:
// create handler function
handleGet := func(w http.ResponseWriter, r *http.Request) {
// handle GET method
}
// create new endpoint
endpoint := endpoints.New()
// map support for GET method
_ = endpoint.AddMethod(http.MethodGet, handleGet)
// mount endpoint to /path
http.Handle("/path", endpoint)