gofiber / fiber

⚡️ Express inspired web framework written in Go
https://gofiber.io
MIT License
33.18k stars 1.64k forks source link

I cannot find any function to read the headers of request 🚀 #1148

Closed abhijitgujar86 closed 3 years ago

abhijitgujar86 commented 3 years ago

Is your feature request related to a problem? It will be good if we have an function to head the header(s) from request Describe the solution you'd like the function can return a json array containing key value objects of headers
Describe alternatives you've considered

Additional context

welcome[bot] commented 3 years ago

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

ReneWerner87 commented 3 years ago

you can fetch individual headers with the ctx.Get function, which is equal to expressjs https://docs.gofiber.io/api/ctx#get https://expressjs.com/de/4x/api.html#req.get

to get to all headers you have to use the functions of fasthttp image

// Header returns request header representation.
ctx.Request().Header.Header()

// PeekBytes returns header value for the given key.
ctx.Request().Header.PeekBytes(BYTE_SLICE)

// Peek returns header value for the given key.
ctx.Request().Header.Peek(STRING)

think with these functions everything should be possible would close the issue if not still questions arise

ReneWerner87 commented 3 years ago

Since there are no more questions or comments, I assume that the last comment has given enough information and I can close the issue, if more questions come up, just open the issue again

cruzluna commented 1 year ago

image