@@ -92,6 +92,7 @@ func (s *serviceImpl) DixInject(
9292 log log.Logger ,
9393 conf * Config ,
9494 gw []* gateway.Mux ,
95+ metadataHandlers []lava.GrpcGatewayMetadata ,
9596) {
9697 s .conf = conf
9798 if conf .HttpPort == nil {
@@ -165,6 +166,11 @@ func (s *serviceImpl) DixInject(
165166 }))
166167 }
167168
169+ httpServer .Use (func (ctx * fiber.Ctx ) error {
170+ ctx .SetUserContext (ctx .Context ())
171+ return ctx .Next ()
172+ })
173+
168174 app := fiber .New ()
169175 app .Group ("/debug" , httputil .StripPrefix (filepath .Join (conf .BaseUrl , "/debug" ), debug .Handler ))
170176
@@ -239,11 +245,17 @@ func (s *serviceImpl) DixInject(
239245 return strings .ToUpper (s ), true
240246 }),
241247 runtime .WithMetadata (func (ctx context.Context , request * http.Request ) metadata.MD {
242- path , ok := runtime .HTTPPathPattern (ctx )
243- if ! ok {
244- return nil
248+ rpcPath , _ := runtime .RPCMethod (ctx )
249+ path , _ := runtime .HTTPPathPattern (ctx )
250+
251+ md := metadata .Pairs ("http_path" , path , "http_method" , request .Method , "http_url" , request .URL .Path )
252+ for _ , h := range metadataHandlers {
253+ for k , v := range h (ctx , request , rpcPath , path ) {
254+ md .Append (k , v ... )
255+ }
245256 }
246- return metadata .Pairs ("http_path" , path , "http_method" , request .Method , "http_url" , request .URL .Path )
257+
258+ return md
247259 }),
248260 runtime .WithErrorHandler (func (ctx context.Context , mux * runtime.ServeMux , marshal runtime.Marshaler , w http.ResponseWriter , request * http.Request , err error ) {
249261 md , ok := runtime .ServerMetadataFromContext (ctx )
0 commit comments