diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-02-15 16:44:29 -0700 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-02-15 16:44:29 -0700 |
commit | 46ad450327111b9d28b592658d75ef57da498298 (patch) | |
tree | 2b837bac9ae36d5a34dda06ba745850da216257d /gemini/roundtrip_test.go | |
parent | bc96af40db6104580c22086c8db7c8119a404257 (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/roundtrip_test.go')
-rw-r--r-- | gemini/roundtrip_test.go | 8 |
1 files changed, 4 insertions, 4 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) |