api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSessionHandlerFunc added in v0.2.0

func CreateSessionHandlerFunc(cache Cache) http.HandlerFunc

CreateSessionHandlerFunc returns a function that generates a session. Method = "POST"

func DeleteAllSessionsHandlerFunc added in v0.2.0

func DeleteAllSessionsHandlerFunc(cache Cache) http.HandlerFunc

func GetByEmailSessionHandlerFunc added in v1.0.0

func GetByEmailSessionHandlerFunc(cache Cache, getVarsFunc GetVarsFunc) http.HandlerFunc

GetByEmailSessionHandlerFunc returns a function that retrieves a session by ID from the cache

func GetByIDSessionHandlerFunc added in v0.2.0

func GetByIDSessionHandlerFunc(cache Cache, getVarsFunc GetVarsFunc) http.HandlerFunc

GetByIDSessionHandlerFunc returns a function that retrieves a session by ID from the cache

Types

type API

type API struct {
	Router *mux.Router
}

API provides a struct to wrap the api around

func Setup

func Setup(ctx context.Context, r *mux.Router, permissions AuthHandler, elasticacheClient *dpredis.Client) *API

func (*API) Close

func (*API) Close(ctx context.Context) error

type AuthHandler added in v0.2.0

type AuthHandler interface {
	Require(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc
}

AuthHandler interface for adding auth to endpoints

type Cache added in v0.2.0

type Cache interface {
	SetSession(s *session.Session) error
	GetByID(ID string) (*session.Session, error)
	GetByEmail(email string) (*session.Session, error)
	DeleteAll() error
}

Cache interface for storing and retrieving sessions

type GetVarsFunc added in v0.2.0

type GetVarsFunc func(r *http.Request) map[string]string

GetVarsFunc is a helper function that returns a map of request variables and parameters

type SessionUpdater added in v0.2.0

type SessionUpdater interface {
	Update(email string) (*session.Session, error)
}

SessionUpdater interface for updating a session

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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