diff options
| author | Adnan Maolood <[email protected]> | 2021-02-23 18:51:58 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-23 18:52:00 -0500 |
| commit | a7c449a3cf2b44d2698cac8cec40d72f3c476f81 (patch) | |
| tree | 2da3964fa68e0415dc58068823a5e6218a329134 /handler.go | |
| parent | Update documentation (diff) | |
| download | go-gemini-a7c449a3cf2b44d2698cac8cec40d72f3c476f81.tar.xz go-gemini-a7c449a3cf2b44d2698cac8cec40d72f3c476f81.zip | |
Use HandlerFunc to implement StatusHandler
Diffstat (limited to 'handler.go')
| -rw-r--r-- | handler.go | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -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 |