aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-23 18:51:58 -0500
committerAdnan Maolood <[email protected]>2021-02-23 18:52:00 -0500
commita7c449a3cf2b44d2698cac8cec40d72f3c476f81 (patch)
tree2da3964fa68e0415dc58068823a5e6218a329134 /handler.go
parentUpdate documentation (diff)
downloadgo-gemini-a7c449a3cf2b44d2698cac8cec40d72f3c476f81.tar.xz
go-gemini-a7c449a3cf2b44d2698cac8cec40d72f3c476f81.zip
Use HandlerFunc to implement StatusHandler
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/handler.go b/handler.go
index e17e9db..4ef6901 100644
--- a/handler.go
+++ b/handler.go
@@ -31,16 +31,9 @@ func (f HandlerFunc) ServeGemini(ctx context.Context, w ResponseWriter, r *Reque
// 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 statusHandler struct {
- status Status
- meta string
-}
-
-func (h *statusHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *Request) {
- w.WriteHeader(h.status, h.meta)
+ return HandlerFunc(func(ctx context.Context, w ResponseWriter, r *Request) {
+ w.WriteHeader(status, meta)
+ })
}
// NotFoundHandler returns a simple request handler that replies to each