Handler returns a sessions middleware to register on application routes. To return the request's Session call the `Get(ctx)` package-level function. Call `Handler()` once per sessions manager.
(requestOptions ...context.CookieOption)
| 180 | // |
| 181 | // Call `Handler()` once per sessions manager. |
| 182 | func (s *Sessions) Handler(requestOptions ...context.CookieOption) context.Handler { |
| 183 | return func(ctx *context.Context) { |
| 184 | session := s.Start(ctx, requestOptions...) // this cookie's end-developer's custom options. |
| 185 | |
| 186 | ctx.Values().Set(sessionContextKey, session) |
| 187 | ctx.Next() |
| 188 | |
| 189 | s.provider.EndRequest(ctx, session) |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // Get returns a *Session from the same request life cycle, |
| 194 | // can be used inside a chain of handlers of a route. |