handling

package
v0.0.0-...-4e988be Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

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

type Handler struct {
	Router     http.Handler
	Config     *config.Config
	Datasource *models.Datasource
}

Handler encompases all request handling

func NewHandler

func NewHandler(config *config.Config) (*Handler, error)

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

func (h *Handler) CheckAuthentication(next http.Handler) http.Handler

CheckAuthentication verifies the user is logged in and has a valid token

func (*Handler) CheckHeaders

func (h *Handler) CheckHeaders(next http.Handler) http.Handler

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) SetConfig

func (h *Handler) SetConfig(next http.Handler) http.Handler

SetConfig makes sure all configuration settings are applied

func (*Handler) SetLogging

func (h *Handler) SetLogging(next http.Handler) http.Handler

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

Jump to

Keyboard shortcuts

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