clean-up grpc-gateway middleware
This commit is contained in:
		| @@ -9,25 +9,9 @@ import ( | |||||||
|  |  | ||||||
| func (aw *AmbientWeather) GetGatewayOpts() []runtime.ServeMuxOption { | func (aw *AmbientWeather) GetGatewayOpts() []runtime.ServeMuxOption { | ||||||
| 	return []runtime.ServeMuxOption{ | 	return []runtime.ServeMuxOption{ | ||||||
| 		runtime.WithMiddlewares(func(hf runtime.HandlerFunc) runtime.HandlerFunc { | 		runtime.WithErrorHandler(func(ctx context.Context, sm *runtime.ServeMux, m runtime.Marshaler, w http.ResponseWriter, req *http.Request, err error) { | ||||||
| 			return func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { | 			aw.GetLogger().Err(err).Msg("error handling gateway request") | ||||||
| 				aw.GetLogger().Trace(). | 			runtime.DefaultHTTPErrorHandler(ctx, sm, m, w, req, err) | ||||||
| 					Any("pathParams", pathParams). |  | ||||||
| 					Msg("inbound request called") |  | ||||||
| 			} |  | ||||||
| 		}), | 		}), | ||||||
| 		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) |  | ||||||
| 			}), |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user