From 46ad450327111b9d28b592658d75ef57da498298 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Wed, 15 Feb 2023 16:44:29 -0700 Subject: 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. --- contrib/cgi/gemini.go | 4 ++-- contrib/cgi/gopher.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'contrib/cgi') diff --git a/contrib/cgi/gemini.go b/contrib/cgi/gemini.go index 8302e7e..1587037 100644 --- a/contrib/cgi/gemini.go +++ b/contrib/cgi/gemini.go @@ -17,7 +17,7 @@ import ( // the URI path. func GeminiCGIDirectory(pathRoot, fsRoot string) gus.Handler { fsRoot = strings.TrimRight(fsRoot, "/") - return func(ctx context.Context, request *gus.Request) *gus.Response { + return gus.HandlerFunc(func(ctx context.Context, request *gus.Request) *gus.Response { if !strings.HasPrefix(request.Path, pathRoot) { return nil } @@ -43,5 +43,5 @@ func GeminiCGIDirectory(pathRoot, fsRoot string) gus.Handler { return gemini.Failure(err) } return response - } + }) } diff --git a/contrib/cgi/gopher.go b/contrib/cgi/gopher.go index 29bfdba..4378eb7 100644 --- a/contrib/cgi/gopher.go +++ b/contrib/cgi/gopher.go @@ -17,7 +17,7 @@ import ( // the URI path. func GopherCGIDirectory(pathRoot, fsRoot string) gus.Handler { fsRoot = strings.TrimRight(fsRoot, "/") - return func(ctx context.Context, request *gus.Request) *gus.Response { + return gus.HandlerFunc(func(ctx context.Context, request *gus.Request) *gus.Response { if !strings.HasPrefix(request.Path, pathRoot) { return nil } @@ -41,5 +41,5 @@ func GopherCGIDirectory(pathRoot, fsRoot string) gus.Handler { } return gopher.File(0, stdout) - } + }) } -- cgit v1.2.3