aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-20 16:15:26 -0500
committerAdnan Maolood <[email protected]>2021-02-20 16:16:32 -0500
commit893803879742057befabc4f6b5d4d412ac6612b6 (patch)
tree6d873d5645af6cbc4332f618e5950568bc1df486 /handler.go
parentTimeoutHandler: Use provided context (diff)
downloadgo-gemini-893803879742057befabc4f6b5d4d412ac6612b6.tar.xz
go-gemini-893803879742057befabc4f6b5d4d412ac6612b6.zip
Make Status a type
Using a type is better than using an integer.
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/handler.go b/handler.go
index a85ba3c..5698e88 100644
--- a/handler.go
+++ b/handler.go
@@ -38,19 +38,19 @@ func (f HandlerFunc) ServeGemini(ctx context.Context, w ResponseWriter, r *Reque
// RedirectHandler returns a request handler that redirects each request it
// receives to the given url using the given status code.
//
-// The provided code should be in the 3x range and is usually
+// The provided status code should be in the 3x range and is usually
// StatusRedirect or StatusPermanentRedirect.
-func RedirectHandler(code int, url string) Handler {
- return &redirectHandler{code, url}
+func RedirectHandler(status Status, url string) Handler {
+ return &redirectHandler{status, url}
}
type redirectHandler struct {
- code int
- url string
+ status Status
+ url string
}
func (h *redirectHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *Request) {
- w.WriteHeader(h.code, h.url)
+ w.WriteHeader(h.status, h.url)
}
// NotFound replies to the request with a Gemini 51 not found error.