Documentation
¶
Index ¶
- Constants
- Variables
- func Bind(db *bolt.DB, source SourceInfo, apiKey auth.Token) (*httprouter.Router, error)
- type API
- type Admin
- func (a *Admin) Bind(r *htr.Router) error
- func (a Admin) DeleteTicket(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (a Admin) DeleteUser(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (a Admin) GetAllProfiles(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (a Admin) NewLogin(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (a Admin) NewTicket(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (a Admin) PatchProfile(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (Admin) Verify(w http.ResponseWriter, r *http.Request, _ htr.Params)
- type Convo
- func (c *Convo) Bind(r *htr.Router) error
- func (c Convo) Connect(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (c Convo) Create(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (c Convo) Delete(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (c Convo) Get(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (c Convo) GetAll(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (c Convo) GetMessages(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (c Convo) Put(w http.ResponseWriter, r *http.Request, ps htr.Params)
- type Incept
- type Notif
- type Profile
- type SourceInfo
- type Stream
- func (s *Stream) Bind(r *htr.Router) error
- func (s Stream) Connect(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (s Stream) Create(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (s Stream) Delete(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (s Stream) Get(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (s Stream) GetAll(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (s Stream) Put(w http.ResponseWriter, r *http.Request, ps htr.Params)
- type Task
- func (t *Task) Bind(r *htr.Router) error
- func (t *Task) Create(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (t *Task) Delete(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (t *Task) Get(w http.ResponseWriter, r *http.Request, ps htr.Params)
- func (t *Task) GetAll(w http.ResponseWriter, r *http.Request, _ htr.Params)
- func (t *Task) Put(w http.ResponseWriter, r *http.Request, ps htr.Params)
- type Token
Constants ¶
const ConvoNotifs = "convos"
ConvoNotifs is the notif code for Convos.
const NotifStream = "notifs"
NotifStream is the streamID to be used for notifs.
const StreamNotifs = "streams"
const TaskNotifs = "tasks"
Variables ¶
var AdminNotifs = "admin"
Functions ¶
func Bind ¶
func Bind( db *bolt.DB, source SourceInfo, apiKey auth.Token, ) (*httprouter.Router, error)
Bind binds the API on the given DB. It sets up REST endpoints as needed.
Types ¶
type API ¶
type API interface {
Bind(*httprouter.Router) error
}
API is a transform on an httprouter.Router, passing a DB for passing on to httprouter.Handles.
type Admin ¶
Admin implements API for an admin token and DB handle.
func (Admin) DeleteTicket ¶
func (Admin) DeleteUser ¶
func (Admin) GetAllProfiles ¶
func (Admin) PatchProfile ¶
PatchProfile is a PATCH handler for an Admin to add Coin to a given user's Profile. The User is notified with the updated Profile value. The caller should use the URL parameter addCoin=<int64 coin amount>.
type Convo ¶
Convo implements API. It manages Convos.
func (Convo) Connect ¶
Connect is a Handle which opens and binds a WebSocket session to a Convo. Messages written by the WS client are bound in a convo.Message with the username and timestamp.
func (Convo) Create ¶
Create is a Handle over the DB which checks that the POSTed Convo is valid and then creates it, returning the created Convo.
func (Convo) Get ¶
Get is a Handle which gets the given Convo by ID. Any user who is an Owner, Reader, or Writer can get a Convo by ID.
func (Convo) GetAll ¶
GetAll is a Handle which writes all Convos owned by the user to the ResponseWriter.
TODO: Make Filters more flexible so users who aren't Owners can also
get Convos they belong to.
func (Convo) GetMessages ¶
GetMessages gets an array of convo.Message. It can have filters applied in order to get a specific range of Messages.
type Incept ¶
Incept implements API on a database. It handles new user creation.
func (Incept) Bind ¶
func (i Incept) Bind(r *httprouter.Router) error
Bind implements API.Bind on Incept.
func (Incept) Incept ¶
func (i Incept) Incept(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
type Notif ¶
Notif implements API. It handles websocket connections to API endpoint notification publishers. A user will receive events on the websocket when an API publishes a notification event to its Pub.
type Profile ¶
Profile implements API. It handles user profiles.
type SourceInfo ¶
type SourceInfo struct { Version store.Version `json:"version"` License string `json:"license"` LicensedTo string `json:"licensedTo"` Location string `json:"location"` }
SourceInfo represents the SG-Proto source location and license, and implements API.
type Stream ¶
Stream implements API. It manages Streams and websocket connections to them.
func (Stream) Connect ¶
Connect is a Handle which opens and binds a WebSocket session to a Stream. The messages are transported as-is.
func (Stream) Create ¶
Create is a Handle over the DB which checks that the POSTed Stream is valid and then creates it, returning the created Stream.
func (Stream) Get ¶
Get is a Handle which gets the given Stream by ID. Any user who is an Owner, Reader, or Writer can get a Stream by ID.