1
0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-09-19 23:01:37 +02:00

Remove NotFound function

This commit is contained in:
adnano 2021-02-20 16:42:18 -05:00
parent b19cfcad16
commit 51e324303b

View File

@ -53,15 +53,12 @@ func (h *redirectHandler) ServeGemini(ctx context.Context, w ResponseWriter, r *
w.WriteHeader(h.status, h.url) w.WriteHeader(h.status, h.url)
} }
// NotFound replies to the request with a Gemini 51 not found error.
func NotFound(ctx context.Context, w ResponseWriter, r *Request) {
w.WriteHeader(StatusNotFound, "Not found")
}
// NotFoundHandler returns a simple request handler that replies to each // NotFoundHandler returns a simple request handler that replies to each
// request with a “51 Not found” reply. // request with a “51 Not found” reply.
func NotFoundHandler() Handler { func NotFoundHandler() Handler {
return HandlerFunc(NotFound) return HandlerFunc(func(ctx context.Context, w ResponseWriter, r *Request) {
w.WriteHeader(StatusNotFound, "Not found")
})
} }
// StripPrefix returns a handler that serves Gemini requests by removing the // StripPrefix returns a handler that serves Gemini requests by removing the
@ -86,7 +83,7 @@ func StripPrefix(prefix string, h Handler) Handler {
r2.URL.RawPath = rp r2.URL.RawPath = rp
h.ServeGemini(ctx, w, r2) h.ServeGemini(ctx, w, r2)
} else { } else {
NotFound(ctx, w, r) w.WriteHeader(StatusNotFound, "Not found")
} }
}) })
} }