diff options
| author | Adnan Maolood <[email protected]> | 2021-02-20 16:44:42 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-20 16:44:42 -0500 |
| commit | 252fe678fd74807b48c500921fb975fe3bb0a7b3 (patch) | |
| tree | 462ba73668dc9144fcbcc3709f6f6d9aaa018157 /handler.go | |
| parent | Remove NotFound function (diff) | |
| download | go-gemini-252fe678fd74807b48c500921fb975fe3bb0a7b3.tar.xz go-gemini-252fe678fd74807b48c500921fb975fe3bb0a7b3.zip | |
Rename RedirectHandler to StatusHandler
Diffstat (limited to 'handler.go')
| -rw-r--r-- | handler.go | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -35,22 +35,19 @@ func (f HandlerFunc) ServeGemini(ctx context.Context, w ResponseWriter, r *Reque f(ctx, w, r) } -// RedirectHandler returns a request handler that redirects each request it -// receives to the given url using the given status code. -// -// The provided status code should be in the 3x range and is usually -// StatusRedirect or StatusPermanentRedirect. -func RedirectHandler(status Status, url string) Handler { - return &redirectHandler{status, url} +// StatusHandler returns a request handler that responds to each request +// with the provided status code and meta. +func StatusHandler(status Status, meta string) Handler { + return &statusHandler{status, meta} } -type redirectHandler struct { +type statusHandler struct { status Status - url string + meta string } -func (h *redirectHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *Request) { - w.WriteHeader(h.status, h.url) +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 |