diff options
| author | Adnan Maolood <[email protected]> | 2021-02-20 16:15:26 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-20 16:16:32 -0500 |
| commit | 893803879742057befabc4f6b5d4d412ac6612b6 (patch) | |
| tree | 6d873d5645af6cbc4332f618e5950568bc1df486 /handler.go | |
| parent | TimeoutHandler: Use provided context (diff) | |
| download | go-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.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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. |