let's say that I need authorization headers, on express node.js I would do something like :
handler = (req, res, next) => {
let BearerToken = req.headers.authorization.split(' ')[1];
next();
}
How can I do this with go fiber?
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
Hi @Badrouu17, Fiber almost uses the same API as Express. Please visit our docs for more information https://docs.gofiber.io/ctx#get
auth := strings.Split(ctx.Get("authorization"), " ")
if len(auth) > 1 {
c.Locals("bearer", auth[1])
}
c.Next()
Hi @Badrouu17, Fiber almost uses the same API as Express. Please visit our docs for more information https://docs.gofiber.io/ctx#get
auth := strings.Split(ctx.Get("authorization"), " ") if len(auth) > 1 { c.Locals("bearer", auth[1]) } c.Next()
@Fenny. Thank you for responding quickly,
I think a better naming for this method would be "Headers()"
anyway keep up the good work guys 馃憦馃憦馃憦
No problem! Like I said before, our API is based on Expressjs. Minimalistic and simple for fast development http://expressjs.com/en/4x/api.html#req.get.
Feel free to close this issue if you don't have further questions :+1: