handlers

package
v0.0.0-...-9ee207d Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthenticatedUser

func GetAuthenticatedUser(h *HandlerContext, r *http.Request) (*users.User, error)

GetAuthenticatedUser fetches the session state from the session store and returns authenticated user

func HandleTestPath

func HandleTestPath(w http.ResponseWriter, r *http.Request)

HandleTestPath handles

func LogUser

func LogUser(h *HandlerContext, r *http.Request, u *users.User) error

LogUser logs all user sing-in attempts to the POST /v1/sessions endpoint returns appropriate http Errors

Types

type CORS

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

CORS struct holds handler that middeware calls

func NewCORS

func NewCORS(handlerToWrap http.Handler) *CORS

NewCORS constructs a new CORSE middleware handler

func (*CORS) ServeHTTP

func (c *CORS) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles the request by adding the appropriate headers and passing it to the real handler

type HandlerContext

type HandlerContext struct {
	SigningKey   string
	SessionStore sessions.Store
	UserStore    users.Store
}

HandlerContext is a reciever for HTTP handler functions

func NewHandlerContext

func NewHandlerContext(sessionKey string, sessionStore sessions.Store, userStore users.Store) *HandlerContext

NewHandlerContext is a constructor for handler context receiver

func (*HandlerContext) SessionsHandler

func (h *HandlerContext) SessionsHandler(w http.ResponseWriter, r *http.Request)

SessionsHandler handles requests for the "sessions" resource also logs when a user tries to sign-in

func (*HandlerContext) SpecificSessionHandler

func (h *HandlerContext) SpecificSessionHandler(w http.ResponseWriter, r *http.Request)

SpecificSessionHandler handles requests related to a specific authenticated session

func (*HandlerContext) SpecificUserHandler

func (h *HandlerContext) SpecificUserHandler(w http.ResponseWriter, r *http.Request)

SpecificUserHandler handles requests for a specific user

func (*HandlerContext) UsersHandler

func (h *HandlerContext) UsersHandler(w http.ResponseWriter, r *http.Request)

UsersHandler handles requests for the "users" resoruce

type SessionState

type SessionState struct {
	Time time.Time   `json:"time"`
	User *users.User `json:"user"`
}

SessionState struct to keep track of begin time and authenticated user

Jump to

Keyboard shortcuts

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