miniflux-v2/http/middleware/context_keys.go

47 lines
1.6 KiB
Go
Raw Normal View History

2017-11-28 06:30:04 +01:00
// Copyright 2017 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package middleware
2017-12-17 03:07:53 +01:00
// ContextKey represents a context key.
type ContextKey struct {
2017-11-28 06:30:04 +01:00
name string
}
2017-12-17 03:07:53 +01:00
func (c ContextKey) String() string {
return c.name
}
2017-11-28 06:30:04 +01:00
var (
// UserIDContextKey is the context key used to store the user ID.
2017-12-17 03:07:53 +01:00
UserIDContextKey = &ContextKey{"UserID"}
2017-11-28 06:30:04 +01:00
// UserTimezoneContextKey is the context key used to store the user timezone.
2017-12-17 03:07:53 +01:00
UserTimezoneContextKey = &ContextKey{"UserTimezone"}
2017-11-28 06:30:04 +01:00
// IsAdminUserContextKey is the context key used to store the user role.
2017-12-17 03:07:53 +01:00
IsAdminUserContextKey = &ContextKey{"IsAdminUser"}
2017-11-28 06:30:04 +01:00
// IsAuthenticatedContextKey is the context key used to store the authentication flag.
2017-12-17 03:07:53 +01:00
IsAuthenticatedContextKey = &ContextKey{"IsAuthenticated"}
// UserSessionTokenContextKey is the context key used to store the user session ID.
UserSessionTokenContextKey = &ContextKey{"UserSessionToken"}
// SessionIDContextKey is the context key used to store the session ID.
SessionIDContextKey = &ContextKey{"SessionID"}
// CSRFContextKey is the context key used to store CSRF token.
CSRFContextKey = &ContextKey{"CSRF"}
// OAuth2StateContextKey is the context key used to store OAuth2 state.
OAuth2StateContextKey = &ContextKey{"OAuth2State"}
// FlashMessageContextKey is the context key used to store a flash message.
FlashMessageContextKey = &ContextKey{"FlashMessage"}
2017-11-28 06:30:04 +01:00
2017-12-17 03:07:53 +01:00
// FlashErrorMessageContextKey is the context key used to store a flash error message.
FlashErrorMessageContextKey = &ContextKey{"FlashErrorMessage"}
2017-11-28 06:30:04 +01:00
)