package router import "net/http" // HTTPHandler adapts net/http handlers to the router. type HTTPHandler struct { w http.ResponseWriter r *http.Request h func(w http.ResponseWriter, r *http.Request, params []string) } // Serve executes the http handler with parameters. func (h *HTTPHandler) Serve(params []string) { h.h(h.w, h.r, params) } // NewHTTP creates a handler from a net/http handler function. func NewHTTP(w http.ResponseWriter, r *http.Request, h func(w http.ResponseWriter, r *http.Request, params []string)) Handler { return &HTTPHandler{w: w, r: r, h: h} }