From 9a2da81b11ad0064cca24ce7974827d032309369 Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 1 May 2023 07:56:25 -0600 Subject: name change gus -> sliderule --- logging/middleware.go | 14 +++++++------- logging/middleware_test.go | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'logging') diff --git a/logging/middleware.go b/logging/middleware.go index 4e23c1e..3b68c15 100644 --- a/logging/middleware.go +++ b/logging/middleware.go @@ -6,12 +6,12 @@ import ( "io" "time" - "tildegit.org/tjp/gus" + sr "tildegit.org/tjp/sliderule" ) -func LogRequests(logger Logger) gus.Middleware { - return func(inner gus.Handler) gus.Handler { - return gus.HandlerFunc(func(ctx context.Context, request *gus.Request) *gus.Response { +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 { response := inner.Handle(ctx, request) if response != nil { response.Body = loggingBody(logger, request, response) @@ -23,8 +23,8 @@ func LogRequests(logger Logger) gus.Middleware { } type loggedResponseBody struct { - request *gus.Request - response *gus.Response + request *sr.Request + response *sr.Response body io.Reader start time.Time @@ -81,7 +81,7 @@ func (lwtr loggedWriteToResponseBody) WriteTo(dst io.Writer) (int64, error) { return n, err } -func loggingBody(logger Logger, request *gus.Request, response *gus.Response) io.Reader { +func loggingBody(logger Logger, request *sr.Request, response *sr.Response) io.Reader { body := &loggedResponseBody{ request: request, response: response, diff --git a/logging/middleware_test.go b/logging/middleware_test.go index 76406ef..390148e 100644 --- a/logging/middleware_test.go +++ b/logging/middleware_test.go @@ -8,17 +8,17 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "tildegit.org/tjp/gus" - "tildegit.org/tjp/gus/logging" + sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/logging" ) func TestLogRequests(t *testing.T) { logger := logRecorder{} - handler := logging.LogRequests(&logger)(gus.HandlerFunc(func(_ context.Context, _ *gus.Request) *gus.Response { - return &gus.Response{} + handler := logging.LogRequests(&logger)(sr.HandlerFunc(func(_ context.Context, _ *sr.Request) *sr.Response { + return &sr.Response{} })) - response := handler.Handle(context.Background(), &gus.Request{}) + response := handler.Handle(context.Background(), &sr.Request{}) _, err := io.ReadAll(response.Body) assert.Nil(t, err) -- cgit v1.2.3