Globally requesting context mapping

Within a global request to request a context mapping solution, there is a single data structure in which you can look up the context for a request. The most popular implementation of this can be found within the Gorilla web toolkit, which can be found here: https://github.com/gorilla/context.

At a very high level, this code creates a single map[*http.Request]map[interface{}]interface{} global variable, which is available through the helper Get and Set functions. When used, if you 'Set' some contextual variable, the code will create a new map[interface{}]interface{}, and uses the request pointer of the request the contextual information belongs to as a map key in the global map, the value of which would ...

Get Echo Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.