handlers

package
v0.0.0-...-711bb3a Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ExposeHeaderCORSHeader = "Access-Control-Expose-Headers"
View Source
const ExposeHeaderCORSValue = "Authorization"
View Source
const HeaderCORSHeader = "Access-Control-Allow-Headers"
View Source
const HeaderCORSValue = "Content-Type, Authorization"
View Source
const MaxAgeCORSHeader = "Access-Control-Max-Age"
View Source
const MaxAgeCORSValue = "600"
View Source
const MethodCORSHeader = "Access-Control-Allow-Methods"
View Source
const MethodCORSValue = "GET, PUT, POST, PATCH, DELETE"
View Source
const OriginCORSHeader = "Access-Control-Allow-Origin"
View Source
const OriginCORSValue = "*"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cors

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

Cors is a middleware handler that allows handler functions to be callable cross-origin

func NewCors

func NewCors(handlerToWrap http.Handler) *Cors

NewCors constructs a new Cors middleware handler

func (*Cors) ServeHTTP

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

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

type HandlerContext

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

func (*HandlerContext) UserLoginHandler

func (ctx *HandlerContext) UserLoginHandler(w http.ResponseWriter, r *http.Request)

UserLoginHandler handles requests for logging in user and returns a session ID. Also handles request for logging out a user

func (*HandlerContext) UserSignUpHandler

func (ctx *HandlerContext) UserSignUpHandler(w http.ResponseWriter, r *http.Request)

UserSignUpHandler handles requests for creating a new customer

type SessionState

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

SessionState stores the start time and the user information for a given session

Jump to

Keyboard shortcuts

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