Documentation ¶
Overview ¶
Package app provides support for the ReST API
Index ¶
- Constants
- func Ok(w http.ResponseWriter, r *http.Request)
- type CreateOrgMsg
- type CreateUserMsg
- 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) ReadOrg(w http.ResponseWriter, r *http.Request)
- func (srv Instance) ReadUser(w http.ResponseWriter, r *http.Request)
- func (srv Instance) RequestLogger(next http.Handler) http.Handler
- func (srv *Instance) Router() *chi.Mux
- func (srv Instance) UpdateOrg(w http.ResponseWriter, r *http.Request)
- func (srv Instance) UpdateUser(w http.ResponseWriter, r *http.Request)
- func (srv *Instance) WithSession(next http.Handler) http.Handler
- func (srv Instance) WithToken(next http.Handler) http.Handler
- type Session
- type Token
- type UpdateOrgOwnerMsg
- type UpdateStatusMsg
- type UpdateUserDisplayNameMsg
- type UpdateUserPasswordMsg
Constants ¶
const ( IDHeader = "X-GrokLOC-ID" TokenRequestHeader = "X-GrokLOC-TokenRequest" )
API headers TokenRequest is formatted as security.EncodedSHA256(id+api-secret)
const ( AuthUser = iota AuthOrg AuthRoot )
Auth levels to be found in ctx with key authLevelCtxKey
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
const (
IDParam = "id"
)
URL parameter names
const Version = "v0"
Version is the current API version
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CreateOrgMsg ¶
type CreateOrgMsg struct {
Name string `json:"name"`
}
CreateOrgMsg is what a client should marshal to send as a json body to CreateOrg
type CreateUserMsg ¶
type CreateUserMsg struct { DisplayName string `json:"display_name"` Email string `json:"email"` Org string `json:"org"` Password string `json:"password"` }
CreateUserMsg is what a client should marshal to send as a json body to CreateUser
type Instance ¶
Instance is a single app server
func (Instance) CreateOrg ¶
func (srv Instance) CreateOrg(w http.ResponseWriter, r *http.Request)
CreateOrg creates a new org based on seed data in the POST body
func (Instance) CreateUser ¶
func (srv Instance) CreateUser(w http.ResponseWriter, r *http.Request)
CreateUser creates a new org based on seed data in the POST body
func (*Instance) NewToken ¶
func (srv *Instance) NewToken(w http.ResponseWriter, r *http.Request)
NewToken returns a response containing a new JWT
func (Instance) ReadOrg ¶
func (srv Instance) ReadOrg(w http.ResponseWriter, r *http.Request)
ReadOrg reads an organization
func (Instance) ReadUser ¶
func (srv Instance) ReadUser(w http.ResponseWriter, r *http.Request)
ReadUser reads a user
func (Instance) RequestLogger ¶
RequestLogger is a middleware that adds logging to each request
func (Instance) UpdateOrg ¶
func (srv Instance) UpdateOrg(w http.ResponseWriter, r *http.Request)
UpdateOrg updates org owner or status
func (Instance) UpdateUser ¶
func (srv Instance) UpdateUser(w http.ResponseWriter, r *http.Request)
UpdateUser updates user display name, password, or status
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.
type UpdateOrgOwnerMsg ¶
type UpdateOrgOwnerMsg struct {
Owner string `json:"owner"`
}
UpdateOrgOwnerMsg is the body format for updating the org owner
func (*UpdateOrgOwnerMsg) UnmarshalJSON ¶
func (m *UpdateOrgOwnerMsg) UnmarshalJSON(bs []byte) error
UnmarshalJSON is a custom unmarshal for UpdateOrgOwnerMsg
type UpdateStatusMsg ¶
UpdateStatusMsg is what a client should marshal to send as a json body to status update endpoints
func (*UpdateStatusMsg) UnmarshalJSON ¶
func (m *UpdateStatusMsg) UnmarshalJSON(bs []byte) error
UnmarshalJSON is a custom unmarshal for UpdateStatusMsg
type UpdateUserDisplayNameMsg ¶
type UpdateUserDisplayNameMsg struct {
DisplayName string `json:"display_name"`
}
UpdateUserDisplayNameMsg is the body format to update the user display name
func (*UpdateUserDisplayNameMsg) UnmarshalJSON ¶
func (m *UpdateUserDisplayNameMsg) UnmarshalJSON(bs []byte) error
UnmarshalJSON is a custom unmarshal for UpdateUserDisplayNameMsg
type UpdateUserPasswordMsg ¶
type UpdateUserPasswordMsg struct {
Password string `json:"password"`
}
UpdateUserPasswordMsg is the body format to update the user password
func (*UpdateUserPasswordMsg) UnmarshalJSON ¶
func (m *UpdateUserPasswordMsg) UnmarshalJSON(bs []byte) error
UnmarshalJSON is a custom unmarshal for UpdateUserPasswordMsg