From a8f62858e05a37cd17acf49fb944bfc8e203e437 Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Wed, 26 Mar 2025 08:31:37 -0400 Subject: [PATCH] clean-up grpc-gateway middleware --- pkg/ambient/app.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/pkg/ambient/app.go b/pkg/ambient/app.go index bbab148..a9ea211 100644 --- a/pkg/ambient/app.go +++ b/pkg/ambient/app.go @@ -9,25 +9,9 @@ import ( func (aw *AmbientWeather) GetGatewayOpts() []runtime.ServeMuxOption { return []runtime.ServeMuxOption{ - runtime.WithMiddlewares(func(hf runtime.HandlerFunc) runtime.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { - aw.GetLogger().Trace(). - Any("pathParams", pathParams). - Msg("inbound request called") - } + runtime.WithErrorHandler(func(ctx context.Context, sm *runtime.ServeMux, m runtime.Marshaler, w http.ResponseWriter, req *http.Request, err error) { + aw.GetLogger().Err(err).Msg("error handling gateway request") + runtime.DefaultHTTPErrorHandler(ctx, sm, m, w, req, err) }), - runtime.WithRoutingErrorHandler( - func( - ctx context.Context, mux *runtime.ServeMux, mshl runtime.Marshaler, - w http.ResponseWriter, r *http.Request, code int, - ) { - aw.GetLogger().Trace(). - Int("code", code). - Str("pattern", r.Pattern). - Msg("requesting grpc-gateway route") - - // Pass back to default - runtime.DefaultRoutingErrorHandler(ctx, mux, mshl, w, r, code) - }), } }