controllers

package
v0.0.0-...-689a9a2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(rw http.ResponseWriter, err error)

BadRequest sends a bad request message to the client.

func IPFromRequest

func IPFromRequest(req *http.Request) net.IP

IPFromRequest extracts the IP from the given request.

func InternalServerError

func InternalServerError(rw http.ResponseWriter, err error)

InternalServerError sends an internal server error to the client.

func Logging

func Logging(req *http.Request, format string, args ...interface{})

Logging writes a message to the logging table in the database.

func SendEmptyJSON

func SendEmptyJSON(rw http.ResponseWriter, code int)

SendEmptyJSON sends an empty JSON document to the client.

func SendFailure

func SendFailure(rw http.ResponseWriter, format string, args ...interface{})

SendFailure sends a failure message to the client.

func SendJSON

func SendJSON(rw http.ResponseWriter, code int, data interface{})

SendJSON sends a JSON representation of the given data to the client.

func SendResult

func SendResult(rw http.ResponseWriter, format string, args ...interface{})

SendResult sends result message to the client.

func SendSuccess

func SendSuccess(rw http.ResponseWriter)

SendSuccess sends a common success message to the client.

func Session

func Session(req *http.Request) *session.Session

Session extracts a session from a given request.

func UserID

func UserID(req *http.Request) int64

UserID extracts the ID of the logged in user from the given request and its associated session.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller encapsulates the state known to all endpoints.

func NewController

func NewController() *Controller

NewController creates a new controller.

func (*Controller) BindRoutes

func (c *Controller) BindRoutes(m *mux.Router)

BindRoutes binds all the the endpoints to the controller.

func (*Controller) Start

func (c *Controller) Start() error

Start starts the logic of the controller running in background.

Jump to

Keyboard shortcuts

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