You can access the request context from the Context property within the Tupa struct.
Context in Middlewares
We can easily add context to a request. In Tupã, there are various ways to work with context through the TupaContext. For example, you can set a new context with the SetContext() method, which will attach the context to the request. To obtain the context value, you can use the GetCtx() and CtxValue(ctx) methods.
GetCtx(): returns the entire request context.
CtxValue(ctx): returns the specific context value according to the specified key.
Let’s add a Context in the MiddlewareSampleRoute() middleware. Note that route-specific middlewares are called first, followed by global middlewares.