diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-08-12 09:40:39 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-08-12 09:40:39 -0600 |
commit | 23bc5f4fb7542e64c94eaa7fe2c7a6aa55010898 (patch) | |
tree | ec8113d3aa2379e3ca9cb3c6e13a5531895ea8c0 /gemini/serve.go | |
parent | 57a31a9b2cd549174d839b9b91b47db337f174cc (diff) |
move common types to an internal package
This helps avoid import cycles.
Diffstat (limited to 'gemini/serve.go')
-rw-r--r-- | gemini/serve.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gemini/serve.go b/gemini/serve.go index 9173212..6fee458 100644 --- a/gemini/serve.go +++ b/gemini/serve.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/internal/types" "tildegit.org/tjp/sliderule/internal" "tildegit.org/tjp/sliderule/logging" ) @@ -19,7 +19,7 @@ import ( type server struct { internal.Server - handler sr.Handler + handler types.Handler } func (s server) Protocol() string { return "GEMINI" } @@ -30,10 +30,10 @@ func NewServer( hostname string, network string, address string, - handler sr.Handler, + handler types.Handler, errorLog logging.Logger, tlsConfig *tls.Config, -) (sr.Server, error) { +) (types.Server, error) { s := &server{handler: handler} hostname = internal.JoinDefaultPort(hostname, "1965") @@ -53,7 +53,7 @@ func NewServer( func (s *server) handleConn(conn net.Conn) { buf := bufio.NewReader(conn) - var response *sr.Response + var response *types.Response request, err := ParseRequest(buf) if err != nil { response = BadRequest(err.Error()) @@ -112,9 +112,9 @@ func sizeParam(path string) (int, error) { // Optionally, it will also allow through titan:// requests. // // Filtered requests will be turned away with a 53 response "proxy request refused". -func GeminiOnly(allowTitan bool) sr.Middleware { - return func(inner sr.Handler) sr.Handler { - return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { +func GeminiOnly(allowTitan bool) types.Middleware { + return func(inner types.Handler) types.Handler { + return types.HandlerFunc(func(ctx context.Context, request *types.Request) *types.Response { if request.Scheme == "gemini" || (allowTitan && request.Scheme == "titan") { return inner.Handle(ctx, request) } |