I have same problem with you. I'm not sure if this is correct but this is how I did it
Use middleware to save Header or RawBody to context.Context
Middlewares: huma.Middlewares{whMdw.SaveHeaderToContext, whMdw.SaveBodyToContext},
func SaveHeaderToContext(ctx huma.Context, next func(huma.Context)) {
webhookHeader := make(map[string]string)
ctx.EachHeader(func(name, value string) {
webhookHeader[name] = value
})
ctx = huma.WithValue(ctx, HeaderKey, webhookHeader)
next(ctx)
}
func SaveBodyToContext(ctx huma.Context, next func(huma.Context)) {
reader := ctx.BodyReader()
if reader == nil {
next(ctx)
return
}
bodyBytes, err := io.ReadAll(reader)
if err != nil {
next(ctx)
return
}
ctx = huma.WithValue(ctx, RawBodyKey, bodyBytes)
next(ctx)
}
And, you can get this data in ctx