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 /logging | |
parent | 57a31a9b2cd549174d839b9b91b47db337f174cc (diff) |
move common types to an internal package
This helps avoid import cycles.
Diffstat (limited to 'logging')
-rw-r--r-- | logging/middleware.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/logging/middleware.go b/logging/middleware.go index 693cb2f..2d0e5b9 100644 --- a/logging/middleware.go +++ b/logging/middleware.go @@ -8,12 +8,12 @@ import ( "io" "time" - sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/internal/types" ) -func LogRequests(logger Logger) sr.Middleware { - return func(inner sr.Handler) sr.Handler { - return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { +func LogRequests(logger Logger) types.Middleware { + return func(inner types.Handler) types.Handler { + return types.HandlerFunc(func(ctx context.Context, request *types.Request) *types.Response { start := time.Now() response := inner.Handle(ctx, request) if response != nil { @@ -38,7 +38,7 @@ func LogRequests(logger Logger) sr.Middleware { } } -func clientFingerprint(request *sr.Request) (string, bool) { +func clientFingerprint(request *types.Request) (string, bool) { if request.TLSState == nil || len(request.TLSState.PeerCertificates) == 0 { return "", false } @@ -48,8 +48,8 @@ func clientFingerprint(request *sr.Request) (string, bool) { } type loggedResponseBody struct { - request *sr.Request - response *sr.Response + request *types.Request + response *types.Response body io.Reader start time.Time @@ -111,7 +111,7 @@ func (lwtr loggedWriteToResponseBody) WriteTo(dst io.Writer) (int64, error) { return n, err } -func loggingBody(logger Logger, request *sr.Request, response *sr.Response, start time.Time) io.Reader { +func loggingBody(logger Logger, request *types.Request, response *types.Response, start time.Time) io.Reader { body := &loggedResponseBody{ request: request, response: response, |