Documentation ¶
Index ¶
- func APIWriteFailure(w http.ResponseWriter, msg string, status int)
- func APIWriteSuccess(w http.ResponseWriter, data interface{})
- type APIResponse
- type Handler
- func (h *Handler) AuthenticateHandler(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CheckAuthentication(next http.Handler) http.Handler
- func (h *Handler) CheckHeaders(next http.Handler) http.Handler
- func (h *Handler) GetChanges(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetUsers(w http.ResponseWriter, r *http.Request)
- func (h *Handler) InsertChange(w http.ResponseWriter, r *http.Request)
- func (h *Handler) InsertUser(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RemoveChange(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RemoveUser(w http.ResponseWriter, r *http.Request)
- func (h *Handler) SetConfig(next http.Handler) http.Handler
- func (h *Handler) SetLogging(next http.Handler) http.Handler
- func (h *Handler) UpdateChange(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateUser(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIWriteFailure ¶
func APIWriteFailure(w http.ResponseWriter, msg string, status int)
APIWriteFailure builds a failure response
func APIWriteSuccess ¶
func APIWriteSuccess(w http.ResponseWriter, data interface{})
APIWriteSuccess builds a success response
Types ¶
type APIResponse ¶
type APIResponse struct { Success bool `json:"success"` Message string `json:"message"` Data interface{} `json:"data"` }
APIResponse creates the structure of an API response
func (APIResponse) WriteJSON ¶
func (j APIResponse) WriteJSON(w http.ResponseWriter, status int)
WriteJSON format a JSON response and write it back to the client
type Handler ¶
Handler encompases all request handling
func NewHandler ¶
NewHandler builds the handler interface and routes
func (*Handler) AuthenticateHandler ¶
func (h *Handler) AuthenticateHandler(w http.ResponseWriter, r *http.Request)
AuthenticateHandler checks the users credentials and issues a token
func (*Handler) CheckAuthentication ¶
CheckAuthentication verifies the user is logged in and has a valid token
func (*Handler) CheckHeaders ¶
CheckHeaders checks the incoming request for valid data
func (*Handler) GetChanges ¶
func (h *Handler) GetChanges(w http.ResponseWriter, r *http.Request)
GetChanges returns a json response with the requested changes
func (*Handler) GetUsers ¶
func (h *Handler) GetUsers(w http.ResponseWriter, r *http.Request)
GetUsers returns a json response with the requested users
func (*Handler) InsertChange ¶
func (h *Handler) InsertChange(w http.ResponseWriter, r *http.Request)
InsertChange inserts a new change into the database
func (*Handler) InsertUser ¶
func (h *Handler) InsertUser(w http.ResponseWriter, r *http.Request)
InsertUser inserts a new user into the database
func (*Handler) RemoveChange ¶
func (h *Handler) RemoveChange(w http.ResponseWriter, r *http.Request)
RemoveChange removes a change from the database
func (*Handler) RemoveUser ¶
func (h *Handler) RemoveUser(w http.ResponseWriter, r *http.Request)
RemoveUser removes a user from the database
func (*Handler) SetLogging ¶
SetLogging enables logging of each request
func (*Handler) UpdateChange ¶
func (h *Handler) UpdateChange(w http.ResponseWriter, r *http.Request)
UpdateChange updates a change database record
func (*Handler) UpdateUser ¶
func (h *Handler) UpdateUser(w http.ResponseWriter, r *http.Request)
UpdateUser updates a user's database record