summaryrefslogtreecommitdiff
path: root/gemini/serve.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-02-15 16:44:29 -0700
committertjpcc <tjp@ctrl-c.club>2023-02-15 16:44:29 -0700
commit46ad450327111b9d28b592658d75ef57da498298 (patch)
tree2b837bac9ae36d5a34dda06ba745850da216257d /gemini/serve.go
parentbc96af40db6104580c22086c8db7c8119a404257 (diff)
Switch Handler to an interface.
HandlerFunc is much better as a function returning a Handler, rather than a newtype for the function type itself. This way there is no confusion creating a type-inferenced variable with HandlerFunc(func(... and then using a HandlerFunc where a Handler is expected. Much better to only have one public type.
Diffstat (limited to 'gemini/serve.go')
-rw-r--r--gemini/serve.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/gemini/serve.go b/gemini/serve.go
index 60e0242..2f93153 100644
--- a/gemini/serve.go
+++ b/gemini/serve.go
@@ -94,7 +94,7 @@ func (s *server) handleConn(conn net.Conn) {
_, _ = io.Copy(conn, NewResponseReader(Failure(err)))
}
}()
- response = s.handler(ctx, request)
+ response = s.handler.Handle(ctx, request)
if response == nil {
response = NotFound("Resource does not exist.")
}
@@ -127,12 +127,12 @@ func sizeParam(path string) (int, error) {
// Filtered requests will be turned away with a 53 response "proxy request refused".
func GeminiOnly(allowTitan bool) gus.Middleware {
return func(inner gus.Handler) gus.Handler {
- return func(ctx context.Context, request *gus.Request) *gus.Response {
+ return gus.HandlerFunc(func(ctx context.Context, request *gus.Request) *gus.Response {
if request.Scheme == "gemini" || (allowTitan && request.Scheme == "titan") {
- return inner(ctx, request)
+ return inner.Handle(ctx, request)
}
return RefuseProxy("Non-gemini protocol requests are not supported.")
- }
+ })
}
}