api

package
v0.0.0-...-64f7ebe Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrivateTokenHeader = "PRIVATE-TOKEN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func New

func New(cfg *config.Config) (*API, error)

Return a new router for the API.

func (*API) GetTokenStore

func (api *API) GetTokenStore() *tokens.TokenStore

Return the token store.

This is intended for use only by unit tests.

func (*API) Serve

func (api *API) Serve() *http.Server

func (*API) ServeHTTP

func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request)

Serve a request.

This is only meant for unit tests since it acquires a lock for every request that would normally only be acquired once in `api.Serve`

func (*API) SetConfig

func (api *API) SetConfig(newConfig *config.Config) error

Update the configuration.

If there is an error setting the configuration (e.g., from attempting to load a new token store), that error will be returned and the configuration will not bet set.

func (*API) Shutdown

func (api *API) Shutdown(server *http.Server) error

type Session

type Session struct {
	PrivateToken string `json:"private_token"`
}

Represents a Session. Currently only holds the private_token, used for authentication. This can be extended in the future to store more session information such as time created, user email, etc.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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