Documentation
¶
Index ¶
- Constants
- func CacheControl(maxAge time.Duration) echo.MiddlewareFunc
- func FilterSentryErrors(next echo.HandlerFunc) echo.HandlerFunc
- func LoadAuthenticatedUser(authClient *authsupport.AuthClient) echo.MiddlewareFunc
- func LoadUser(authClient *authsupport.AuthClient) echo.MiddlewareFunc
- func LoadValidPasswordToken(authClient *authsupport.AuthClient) echo.MiddlewareFunc
- func LogRequestID() echo.MiddlewareFunc
- func RateLimit(store ratelimit.Store, max int, window time.Duration) echo.MiddlewareFunc
- func RecoverPanics(logger echo.Logger) echo.MiddlewareFunc
- func RequireAdmin() echo.MiddlewareFunc
- func RequireAuthentication() echo.MiddlewareFunc
- func RequireNoAuthentication() echo.MiddlewareFunc
- func ServeCachedPage(ch *cacherepo.CacheClient) echo.MiddlewareFunc
- func SetDeviceTypeToServe() echo.MiddlewareFunc
- func SetLastSeenOnline(authClient *authsupport.AuthClient) echo.MiddlewareFunc
- type CachedPage
Constants ¶
const CachedPageGroup = "page"
CachedPageGroup stores the cache group for cached pages
Variables ¶
This section is empty.
Functions ¶
func CacheControl ¶
func CacheControl(maxAge time.Duration) echo.MiddlewareFunc
CacheControl sets a Cache-Control header with a given max age
func FilterSentryErrors ¶
func FilterSentryErrors(next echo.HandlerFunc) echo.HandlerFunc
func LoadAuthenticatedUser ¶
func LoadAuthenticatedUser(authClient *authsupport.AuthClient) echo.MiddlewareFunc
LoadAuthenticatedUser loads the authenticated user, if one, and stores in context
func LoadUser ¶
func LoadUser(authClient *authsupport.AuthClient) echo.MiddlewareFunc
LoadUser loads the user based on the ID provided as a path parameter
func LoadValidPasswordToken ¶
func LoadValidPasswordToken(authClient *authsupport.AuthClient) echo.MiddlewareFunc
LoadValidPasswordToken loads a valid password token entity that matches the user and token provided in path parameters If the token is invalid, the user will be redirected to the forgot password route This requires that the user ID owning the token is loaded in context (e.g. by LoadUser middleware).
func LogRequestID ¶
func LogRequestID() echo.MiddlewareFunc
LogRequestID includes the request ID in all logs for the given request This requires that middleware that includes the request ID first execute
func RateLimit ¶
RateLimit limits requests by route+method and caller identity. Authenticated users are keyed by user ID; anonymous requests are keyed by IP.
func RecoverPanics ¶
func RecoverPanics(logger echo.Logger) echo.MiddlewareFunc
RecoverPanics wraps Echo's recovery middleware and emits structured panic logs.
func RequireAdmin ¶
func RequireAdmin() echo.MiddlewareFunc
RequireAdmin requires an authenticated admin user.
func RequireAuthentication ¶
func RequireAuthentication() echo.MiddlewareFunc
RequireAuthentication requires that the user be authenticated in order to proceed
func RequireNoAuthentication ¶
func RequireNoAuthentication() echo.MiddlewareFunc
RequireNoAuthentication requires that the user not be authenticated in order to proceed
func ServeCachedPage ¶
func ServeCachedPage(ch *cacherepo.CacheClient) echo.MiddlewareFunc
ServeCachedPage attempts to load a page from the cache by matching on the complete request URL If a page is cached for the requested URL, it will be served here and the request terminated. Any request made by an authenticated user or that is not a GET will be skipped.
func SetDeviceTypeToServe ¶
func SetDeviceTypeToServe() echo.MiddlewareFunc
LoadAuthenticatedUser loads the authenticated user, if one, and stores in context
func SetLastSeenOnline ¶
func SetLastSeenOnline(authClient *authsupport.AuthClient) echo.MiddlewareFunc
LoadAuthenticatedUser loads the authenticated user, if one, and stores in context
Types ¶
type CachedPage ¶
type CachedPage struct {
// URL stores the URL of the requested page
URL string
// HTML stores the complete HTML of the rendered Page
HTML []byte
// StatusCode stores the HTTP status code
StatusCode int
// Headers stores the HTTP headers
Headers map[string]string
}
CachedPage is what is used to store a rendered Page in the cache