aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-20 16:44:42 -0500
committerAdnan Maolood <[email protected]>2021-02-20 16:44:42 -0500
commit252fe678fd74807b48c500921fb975fe3bb0a7b3 (patch)
tree462ba73668dc9144fcbcc3709f6f6d9aaa018157 /handler.go
parentRemove NotFound function (diff)
downloadgo-gemini-252fe678fd74807b48c500921fb975fe3bb0a7b3.tar.xz
go-gemini-252fe678fd74807b48c500921fb975fe3bb0a7b3.zip
Rename RedirectHandler to StatusHandler
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/handler.go b/handler.go
index b3b2b23..2970fd0 100644
--- a/handler.go
+++ b/handler.go
@@ -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