api

package
v0.0.0-...-10cef3e Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CookieAuthKey is the cookie key that will be used to set the client authorization cookie
	CookieAuthKey = "auth-token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is the magic behind the api

func New

func New(db *database.DB, config *config.Config) *API

New declares a new API instance

func (*API) Handler

func (s *API) Handler() http.Handler

Handler returns an http.Handler for the route /api

func (*API) JwtMiddleware

func (s *API) JwtMiddleware(next http.Handler) http.Handler

JwtMiddleware is a middleware that attaches the user to the request context

func (*API) Login

func (s *API) Login(w http.ResponseWriter, r *http.Request)

Login is the handler behind /api/auth/login.

func (*API) MustBeAdmin

func (s *API) MustBeAdmin(next http.Handler) http.Handler

MustBeAdmin is a middleware that makes sure that the user creating the request is an admin.

func (*API) MustBeAuthed

func (s *API) MustBeAuthed(next http.Handler) http.Handler

MustBeAuthed is a middleware that makes sure that the user creating the request is authenticated.

func (*API) MustBeProposer

func (s *API) MustBeProposer(next http.Handler) http.Handler

MustBeProposer is a middleware that makes sure that the user creating the request is a proposer.

func (*API) Signup

func (s *API) Signup(w http.ResponseWriter, r *http.Request)

Signup is the handler behind /api/auth/signup.

Jump to

Keyboard shortcuts

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