diff options
Diffstat (limited to 'http/handler.go')
-rw-r--r-- | http/handler.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/http/handler.go b/http/handler.go index 9f47bff..c53655b 100644 --- a/http/handler.go +++ b/http/handler.go @@ -7,18 +7,18 @@ import ( g "github.com/maragudk/gomponents" ) -// Handler is like http.Handler but returns a Node and an error. -// See Adapt for how errors are translated to HTTP responses. +// Handler is like [http.Handler] but returns a [g.Node] and an error. +// See [Adapt] for how errors are translated to HTTP responses. type Handler = func(http.ResponseWriter, *http.Request) (g.Node, error) type errorWithStatusCode interface { StatusCode() int } -// Adapt a Handler to a http.Handlerfunc. -// The returned Node is rendered to the ResponseWriter, in both normal and error cases. -// If the Handler returns an error, and it implements a "StatusCode() int" method, that HTTP status code is sent -// in the response header. Otherwise, the status code http.StatusInternalServerError (500) is used. +// Adapt a [Handler] to a [http.HandlerFunc]. +// The returned [g.Node] is rendered to the [http.ResponseWriter], in both normal and error cases. +// If the [Handler] returns an error, and it implements a "StatusCode() int" method, that HTTP status code is sent +// in the response header. Otherwise, the status code [http.StatusInternalServerError] (500) is used. func Adapt(h Handler) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { n, err := h(w, r) |