diff options
Diffstat (limited to 'gemini')
-rw-r--r-- | gemini/roundtrip_test.go | 8 | ||||
-rw-r--r-- | gemini/serve.go | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/gemini/roundtrip_test.go b/gemini/roundtrip_test.go index a9d9b59..e8d2b48 100644 --- a/gemini/roundtrip_test.go +++ b/gemini/roundtrip_test.go @@ -20,9 +20,9 @@ func TestRoundTrip(t *testing.T) { tlsConf, err := gemini.FileTLS("./testdata/server.crt", "./testdata/server.key") require.Nil(t, err) - handler := func(ctx context.Context, req *gus.Request) *gus.Response { + handler := gus.HandlerFunc(func(ctx context.Context, req *gus.Request) *gus.Response { return gemini.Success("text/gemini", bytes.NewBufferString("you've found my page")) - } + }) server, err := gemini.NewServer(context.Background(), "localhost", "tcp", "127.0.0.1:0", handler, nil, tlsConf) require.Nil(t, err) @@ -54,7 +54,7 @@ func TestTitanRequest(t *testing.T) { require.Nil(t, err) invoked := false - handler := func(ctx context.Context, request *gus.Request) *gus.Response { + handler := gus.HandlerFunc(func(ctx context.Context, request *gus.Request) *gus.Response { invoked = true body := ctx.Value(gemini.TitanRequestBody) @@ -67,7 +67,7 @@ func TestTitanRequest(t *testing.T) { assert.Equal(t, "the request body\n", string(bodyBytes)) return gemini.Success("", nil) - } + }) server, err := gemini.NewServer(context.Background(), "localhost", "tcp", "127.0.0.1:0", handler, nil, tlsConf) require.Nil(t, err) 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.") - } + }) } } |