Fiber: 馃 How to modify fiber.Ctx?

Created on 17 Feb 2020  路  2Comments  路  Source: gofiber/fiber

Question description

In Express, it's possible to dangle any sort of custom methods or properties from the request/response objects via middleware. I can't see anything in the documentation of how to do this in Fiber.

For instance, I want to write middleware that deals with some authentication that gives me an API in my route handlers that allows me to check for permissions or call an upstream service, how would this be done?

Most helpful comment

We are planning to add a feature to extend the Ctx struct, but this will be released in v2.
For now you could use a function called Locals for passing data between middlewares.

Click here for an example, does this help?

All 2 comments

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template!

We are planning to add a feature to extend the Ctx struct, but this will be released in v2.
For now you could use a function called Locals for passing data between middlewares.

Click here for an example, does this help?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeyraj picture jeyraj  路  4Comments

MohamedGouaouri picture MohamedGouaouri  路  3Comments

peterbourgon picture peterbourgon  路  4Comments

abowloflrf picture abowloflrf  路  4Comments

GrigoriyMikhalkin picture GrigoriyMikhalkin  路  4Comments