middleware

package
v0.0.0-...-baa204d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package middleware provides functions to inspect and transform incoming requests before they're routed out to their corrrect handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppsOpenOnly

func AppsOpenOnly(h http.Handler) http.Handler

AppsOpenOnly makes sure the APP_STATUS environment variable is either 2 or 4, if it's outside of that then

func LimitRequestSize

func LimitRequestSize(next http.Handler) http.Handler

LimitRequestSize prevents requests from being over 32MiB

func LiveOnly

func LiveOnly(h http.Handler) http.Handler

LiveOnly makes sure that the APP_STATUS environment variable is only 4, if it's outside of that then return 404

func Logging

func Logging(next http.Handler) http.Handler

Logging will log some gosh darn neat stuff.

func MustBeAuthenticated

func MustBeAuthenticated(h http.Handler) http.Handler

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

func MustBeExec(h http.Handler) http.Handler

MustBeExec only allows execs roles to access a route

func MustNotBeAuthenticated

func MustNotBeAuthenticated(h http.Handler) http.Handler

MustNotBeAuthenticated is the same as MustBeAuthenticated but it does the opposite.

func OnSeasonOnly

func OnSeasonOnly(h http.Handler) http.Handler

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

func Recoverer(next http.Handler) http.Handler

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.

func SetContentTypeJSON

func SetContentTypeJSON(next http.Handler) http.Handler

SetContentTypeJSON sets the Content-Type for a response to application/json

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL