Skip to content
Snippets Groups Projects
Commit 28f40875 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

fix issue with missing credentials in ctx via gRPC gateway

parent 57ca221f
No related branches found
No related tags found
No related merge requests found
Pipeline #186771 failed
This commit is part of merge request !794. Comments created here will be created in the context of that merge request.
...@@ -42,7 +42,9 @@ func run() error { ...@@ -42,7 +42,9 @@ func run() error {
// Register gRPC server endpoint // Register gRPC server endpoint
// Note: Make sure the gRPC server is running properly and accessible // Note: Make sure the gRPC server is running properly and accessible
mux := runtime.NewServeMux() mux := runtime.NewServeMux(
runtime.WithIncomingHeaderMatcher(customHeaderMatcher),
)
err := registerHttpHandler(mux) err := registerHttpHandler(mux)
...@@ -162,3 +164,14 @@ func metricsHandler(mux *runtime.ServeMux) error { ...@@ -162,3 +164,14 @@ func metricsHandler(mux *runtime.ServeMux) error {
return nil return nil
} }
// customHeaderMatcher passes custom key-value pairs within headers to be added to the outgoing context of gRPC-Gateway.
// Use "authorize: token" in header for authorization after login.
func customHeaderMatcher(key string) (string, bool) {
switch key {
case "Authorize":
return key, true
default:
return runtime.DefaultHeaderMatcher(key)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment