Documentation ¶
Overview ¶
Package server defines the ReST service
Index ¶
- Constants
- func Ok(w http.ResponseWriter, r *http.Request)
- type Instance
- func (srv *Instance) CreateOrg(w http.ResponseWriter, r *http.Request)
- func (srv *Instance) CreateUser(w http.ResponseWriter, r *http.Request)
- func (srv *Instance) NewToken(w http.ResponseWriter, r *http.Request)
- func (srv *Instance) RequestLogger(next http.Handler) http.Handler
- func (srv *Instance) Router() *chi.Mux
- func (srv *Instance) WithSession(next http.Handler) http.Handler
- func (srv Instance) WithToken(next http.Handler) http.Handler
- type Session
- type Token
Constants ¶
View Source
const ( APIPath = "/api/" + Version TokenRoute = APIPath + "/token" OkPath = "/ok" OkRoute = APIPath + OkPath OrgPath = "/org" OrgRoute = APIPath + OrgPath StatusPath = "/status" StatusRoute = APIPath + StatusPath // auth + Ok UserPath = "/user" UserRoute = APIPath + UserPath )
path/route constants
View Source
const ( IDHeader = "X-GrokLOC-ID" TokenRequestHeader = "X-GrokLOC-TokenRequest" )
API headers TokenRequest is formatted as security.EncodedSHA256(id+api-secret)
View Source
const ( AuthUser = iota AuthOrg AuthRoot )
Auth levels to be found in ctx with key authLevelCtxKey
View Source
const (
IDParam = "id"
)
URL parameter names
View Source
const Version = "v0"
Version is the current API version
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Instance ¶
type Instance struct { ST *app.State Started time.Time OrgController *org.Controller UserController *user.Controller }
Instance is a single app server
func (*Instance) CreateUser ¶
func (srv *Instance) CreateUser(w http.ResponseWriter, r *http.Request)
func (*Instance) NewToken ¶
func (srv *Instance) NewToken(w http.ResponseWriter, r *http.Request)
NewToken returns a response containing a new JWT
func (*Instance) RequestLogger ¶
RequestLogger is a middleware that adds logging to each request
func (*Instance) WithSession ¶
WithSession reads the user and org using the X-GrokLOC-ID header, performs basic validation, and then adds a user and org instance to the context.
Click to show internal directories.
Click to hide internal directories.