Rename RedirectHandler to StatusHandler
This commit is contained in:
parent
351fb92c7e
commit
252fe678fd
19
handler.go
19
handler.go
@ -35,22 +35,19 @@ func (f HandlerFunc) ServeGemini(ctx context.Context, w ResponseWriter, r *Reque
|
|||||||
f(ctx, w, r)
|
f(ctx, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RedirectHandler returns a request handler that redirects each request it
|
// StatusHandler returns a request handler that responds to each request
|
||||||
// receives to the given url using the given status code.
|
// with the provided status code and meta.
|
||||||
//
|
func StatusHandler(status Status, meta string) Handler {
|
||||||
// The provided status code should be in the 3x range and is usually
|
return &statusHandler{status, meta}
|
||||||
// StatusRedirect or StatusPermanentRedirect.
|
|
||||||
func RedirectHandler(status Status, url string) Handler {
|
|
||||||
return &redirectHandler{status, url}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type redirectHandler struct {
|
type statusHandler struct {
|
||||||
status Status
|
status Status
|
||||||
url string
|
meta string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *redirectHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *Request) {
|
func (h *statusHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *Request) {
|
||||||
w.WriteHeader(h.status, h.url)
|
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