From 23bc5f4fb7542e64c94eaa7fe2c7a6aa55010898 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sat, 12 Aug 2023 09:40:39 -0600 Subject: move common types to an internal package This helps avoid import cycles. --- logging/middleware.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'logging') 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, -- cgit v1.2.3