Open spa5k opened 4 months ago
It's because huma.Context.Header
reads request headers, but huma.Context.SetHeader
sets response headers.
So this set header is only for response? I can't update the headers of the request when it reaches Middleware?
Yes. At least for now you can only do this in router own middleware.
@spa5k if you must override headers in router-agnostic middleware, you can create your own struct which wraps huma.Context
and override yourStruct.Header(name string) string
to return the values you want. Otherwise, like @x-user says you can do this in the underlying router's own middlewares.
imo, it should forward the headers naturally, how do other framework/languages handle it?
So I have a small middleware that reads the cookie and writes a "User-Id" header through the context, but when I try to read the same header in the handler or in the next middleware, it remains empty
Passing values through context is working as expected.