From 48d77a965c761e2627401c629c42340c40b1f87b Mon Sep 17 00:00:00 2001 From: Tal Gendler Date: Mon, 16 Nov 2020 11:34:48 +0200 Subject: [PATCH] fix HTTPHandler typo --- README.md | 4 ++-- http/client/httpclient.go | 4 ++-- http/client/httpclient_test.go | 2 +- interfaces/http/client/interfaces.go | 6 +++--- middleware/interceptors/trace/client.go | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 98f9df1..7666c70 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ When you done, read the [documentation](https://github.com/go-masonry/tutorial) * Log/Dump requests and/or responses when http request fails. ```golang - return func(req *http.Request, handler client.HTTPpHandler) (resp *http.Response, err error) { + return func(req *http.Request, handler client.HTTPHandler) (resp *http.Response, err error) { var reqBytes, respBytes []byte // If the response is Bad Request, log both Request and Response reqBytes, _ = httputil.DumpRequestOut(req, true) // it can be nil and it's ok @@ -57,7 +57,7 @@ When you done, read the [documentation](https://github.com/go-masonry/tutorial) * Alter requests and/or responses (useful in [Tests](https://github.com/go-masonry/mortar-demo/blob/master/workshop/app/controllers/workshop_test.go#L162)) ```golang - func(*http.Request, clientInt.HTTPpHandler) (*http.Response, error) { + func(*http.Request, clientInt.HTTPHandler) (*http.Response, error) { // special case, don't go anywhere just return the response return &http.Response{ Status: "200 OK", diff --git a/http/client/httpclient.go b/http/client/httpclient.go index a3bf86b..29c1854 100644 --- a/http/client/httpclient.go +++ b/http/client/httpclient.go @@ -78,13 +78,13 @@ func (crt *customRoundTripper) RoundTrip(req *http.Request) (*http.Response, err func uniteInterceptors(interceptors []client.HTTPClientInterceptor) client.HTTPClientInterceptor { if len(interceptors) == 0 { - return func(req *http.Request, handler client.HTTPpHandler) (*http.Response, error) { + return func(req *http.Request, handler client.HTTPHandler) (*http.Response, error) { // That's why we needed an alias to http.RoundTripper.RoundTrip return handler(req) } } - return func(req *http.Request, handler client.HTTPpHandler) (*http.Response, error) { + return func(req *http.Request, handler client.HTTPHandler) (*http.Response, error) { tailHandler := func(innerReq *http.Request) (*http.Response, error) { unitedInterceptor := uniteInterceptors(interceptors[1:]) return unitedInterceptor(req, handler) diff --git a/http/client/httpclient_test.go b/http/client/httpclient_test.go index 01ffd7b..5c9e608 100644 --- a/http/client/httpclient_test.go +++ b/http/client/httpclient_test.go @@ -39,7 +39,7 @@ func TestWithInterceptor(t *testing.T) { require.Equal(t, "Pike", family) } -func testInterceptor(req *http.Request, handler client.HTTPpHandler) (resp *http.Response, err error) { +func testInterceptor(req *http.Request, handler client.HTTPHandler) (resp *http.Response, err error) { req.Header.Set("name", "Robert") if resp, err = handler(req); err == nil { resp.Header.Set("family", "Pike") diff --git a/interfaces/http/client/interfaces.go b/interfaces/http/client/interfaces.go index 2502383..5430762 100644 --- a/interfaces/http/client/interfaces.go +++ b/interfaces/http/client/interfaces.go @@ -13,12 +13,12 @@ import ( // http.Client //******************************************************************************** -// HTTPpHandler is just an alias to http.RoundTriper.RoundTrip function -type HTTPpHandler func(*http.Request) (*http.Response, error) +// HTTPHandler is just an alias to http.RoundTriper.RoundTrip function +type HTTPHandler func(*http.Request) (*http.Response, error) // HTTPClientInterceptor is a user defined function that can alter a request before it's sent // and/or alter a response before it's returned to the caller -type HTTPClientInterceptor func(*http.Request, HTTPpHandler) (*http.Response, error) +type HTTPClientInterceptor func(*http.Request, HTTPHandler) (*http.Response, error) // HTTPClientBuilder is a builder interface to build http.Client with interceptors type HTTPClientBuilder interface { diff --git a/middleware/interceptors/trace/client.go b/middleware/interceptors/trace/client.go index fe051dc..d6b9fb1 100644 --- a/middleware/interceptors/trace/client.go +++ b/middleware/interceptors/trace/client.go @@ -42,7 +42,7 @@ func TracerGRPCClientInterceptor(deps tracingDeps) grpc.UnaryClientInterceptor { // TracerRESTClientInterceptor is a REST tracing client interceptor, it can log req/resp if needed func TracerRESTClientInterceptor(deps tracingDeps) client.HTTPClientInterceptor { - return func(req *http.Request, handler client.HTTPpHandler) (resp *http.Response, err error) { + return func(req *http.Request, handler client.HTTPHandler) (resp *http.Response, err error) { if deps.Tracer == nil { return handler(req) }