34 lines
895 B
Go
34 lines
895 B
Go
package ambient
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
|
)
|
|
|
|
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.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)
|
|
}),
|
|
}
|
|
}
|