Documentation ¶
Overview ¶
Package middleware provides functions to inspect and transform incoming requests before they're routed out to their corrrect handler.
Index ¶
- func AppsOpenOnly(h http.Handler) http.Handler
- func LimitRequestSize(next http.Handler) http.Handler
- func LiveOnly(h http.Handler) http.Handler
- func Logging(next http.Handler) http.Handler
- func MustBeAuthenticated(h http.Handler) http.Handler
- func MustBeExec(h http.Handler) http.Handler
- func MustNotBeAuthenticated(h http.Handler) http.Handler
- func OnSeasonOnly(h http.Handler) http.Handler
- func Recoverer(next http.Handler) http.Handler
- func SetContentTypeJSON(next http.Handler) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppsOpenOnly ¶
AppsOpenOnly makes sure the APP_STATUS environment variable is either 2 or 4, if it's outside of that then
func LimitRequestSize ¶
LimitRequestSize prevents requests from being over 32MiB
func LiveOnly ¶
LiveOnly makes sure that the APP_STATUS environment variable is only 4, if it's outside of that then return 404
func MustBeAuthenticated ¶
MustBeAuthenticated enforces that a user sending a request is logged in. It checks this by seeing if the session has a non empty email. If the session does not have an email then that means the session is not valid and so the request is redirected to the login page.
func MustBeExec ¶
MustBeExec only allows execs roles to access a route
func MustNotBeAuthenticated ¶
MustNotBeAuthenticated is the same as MustBeAuthenticated but it does the opposite.
func OnSeasonOnly ¶
OnSeasonOnly makes sure the APP_STATUS environment variable is between 2 and 4, if it's outside of that then the handler returns 404 instead
func Recoverer ¶
Recoverer recovers from a panic that a was hit while handling a request. Ideally, it should never be run because ideally nothing will panic. In the case that does happen, this will prevent the entire server from shutting down. It will also log the error (and report it to rollbar), and render the status code 500 page.
Types ¶
This section is empty.