context_keys.go 860 B

1234567891011121314151617181920212223242526
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package middleware
  5. type contextKey struct {
  6. name string
  7. }
  8. var (
  9. // UserIDContextKey is the context key used to store the user ID.
  10. UserIDContextKey = &contextKey{"UserID"}
  11. // UserTimezoneContextKey is the context key used to store the user timezone.
  12. UserTimezoneContextKey = &contextKey{"UserTimezone"}
  13. // IsAdminUserContextKey is the context key used to store the user role.
  14. IsAdminUserContextKey = &contextKey{"IsAdminUser"}
  15. // IsAuthenticatedContextKey is the context key used to store the authentication flag.
  16. IsAuthenticatedContextKey = &contextKey{"IsAuthenticated"}
  17. // TokenContextKey is the context key used to store CSRF token.
  18. TokenContextKey = &contextKey{"CSRF"}
  19. )