Documentation ¶
Overview ¶
Package middleware provides functions to inspect and transform incoming requests before they're routed out to their corrrect handler.
Index ¶
- func LimitRequestSize(next 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 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 LimitRequestSize ¶
LimitRequestSize prevents requests from being over 32MiB
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 and admin roles to access a route
func MustNotBeAuthenticated ¶
MustNotBeAuthenticated is the same as MustBeAuthenticated but it does the opposite.
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.