Use HandlerFunc to implement StatusHandler
This commit is contained in:
parent
02bbedc330
commit
a7c449a3cf
13
handler.go
13
handler.go
|
@ -31,16 +31,9 @@ func (f HandlerFunc) ServeGemini(ctx context.Context, w ResponseWriter, r *Reque
|
||||||
// StatusHandler returns a request handler that responds to each request
|
// StatusHandler returns a request handler that responds to each request
|
||||||
// with the provided status code and meta.
|
// with the provided status code and meta.
|
||||||
func StatusHandler(status Status, meta string) Handler {
|
func StatusHandler(status Status, meta string) Handler {
|
||||||
return &statusHandler{status, meta}
|
return HandlerFunc(func(ctx context.Context, w ResponseWriter, r *Request) {
|
||||||
}
|
w.WriteHeader(status, meta)
|
||||||
|
})
|
||||||
type statusHandler struct {
|
|
||||||
status Status
|
|
||||||
meta string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *statusHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *Request) {
|
|
||||||
w.WriteHeader(h.status, h.meta)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotFoundHandler returns a simple request handler that replies to each
|
// NotFoundHandler returns a simple request handler that replies to each
|
||||||
|
|
Loading…
Reference in New Issue
Block a user