api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NOPSessionID = "123"
	NOPStart     = "Mon Jan _2 15:04:05 2006"
)

Variables

This section is empty.

Functions

func CreateSessionHandlerFunc added in v0.2.0

func CreateSessionHandlerFunc(sessionUpdater SessionUpdater, 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 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) *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 {
	Set(s *session.Session) error
	GetByID(ID 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 NOPCache added in v0.2.0

type NOPCache struct{}

NOPCache no-op struct

func (*NOPCache) DeleteAll added in v0.2.0

func (n *NOPCache) DeleteAll() error

DeleteAll removes all sessions from the cache

func (*NOPCache) GetByID added in v0.2.0

func (n *NOPCache) GetByID(ID string) (*session.Session, error)

GetByID retrieves a session from the cache by ID

func (*NOPCache) Set added in v0.2.0

func (n *NOPCache) Set(s *session.Session) error

Set stores a session into the cache

type NOPSession added in v0.2.0

type NOPSession struct{}

NOPSessions no-op struct

func (*NOPSession) Update added in v0.2.0

func (n *NOPSession) Update(email string) (*session.Session, error)

New creates a new session using an email address

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