middleware

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentTypeJSON

func ContentTypeJSON(next http.Handler) http.Handler

ContentTypeJSON sets the content type for requests to application/json

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth implements the authorization functions

func NewAuth

func NewAuth(
	store sessions.Store,
	cookieName string,
) *Auth

NewAuth returns a new Auth instance

func (*Auth) BasicAuthenticate

func (auth *Auth) BasicAuthenticate(next http.Handler) http.Handler

BasicAuthenticate just checks that a user is logged in

func (*Auth) DoesUserIDMatch

func (auth *Auth) DoesUserIDMatch(next http.Handler, loc IDLocation) http.Handler

DoesUserIDMatch checks the id URL parameter and verifies that it matches the one stored in the session

type IDLocation

type IDLocation uint

IDLocation represents the location of the ID to use for authentication

const (
	// URLParam location looks for {id} in the URL
	URLParam IDLocation = iota
	// BodyParam location looks for user_id in the body
	BodyParam
)

Jump to

Keyboard shortcuts

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