controllers

package
v0.0.0-...-3295dff Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2018 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(rtr *httprouter.Router, controller WebController)

Registers an array of route handlers to gorilla/mux

func SubscribeNatsRoutes

func SubscribeNatsRoutes(natsCon *natsio.Nats, queueName string, controllers NatsController)

Types

type BaseController

type BaseController struct{}

func (*BaseController) AcceptsHtml

func (bC *BaseController) AcceptsHtml(r *http.Request) bool

func (*BaseController) AcceptsJson

func (bC *BaseController) AcceptsJson(r *http.Request) bool

func (*BaseController) AcceptsXml

func (bC *BaseController) AcceptsXml(r *http.Request) bool

func (*BaseController) QueryInt

func (bC *BaseController) QueryInt(r *http.Request, param string) (int, error)

Gets first query string value as int

func (*BaseController) QueryInterfaceMap

func (bC *BaseController) QueryInterfaceMap(r *http.Request, param string, target interface{}) (ifMap map[string]interface{})

Uses byrnedo/mapcast to turn query string map into a typed map.

func (*BaseController) QueryMap

func (bC *BaseController) QueryMap(r *http.Request, param string) map[string]string

Makes a map from a query string parameter formatted so that a query string like ?query=field:val&query=field:val2 becomes

map[string]string{"field": {
		"val",
		"val2",
}

func (*BaseController) SendsHtml

func (bC *BaseController) SendsHtml(r *http.Request) bool

func (*BaseController) SendsJson

func (bC *BaseController) SendsJson(r *http.Request) bool

func (*BaseController) SendsXml

func (bC *BaseController) SendsXml(r *http.Request) bool

type JsonController

type JsonController struct {
	BaseController
}

Controller with json helpers

func (*JsonController) Serve

func (jC *JsonController) Serve(w http.ResponseWriter, data interface{})

Serve standard 200

func (*JsonController) ServeWithStatus

func (jC *JsonController) ServeWithStatus(w http.ResponseWriter, data interface{}, status int)

Serve with custom status

type NatsController

type NatsController interface {
	GetRoutes() []*routes.NatsRoute
}

type WebController

type WebController interface {
	GetRoutes() []*routes.WebRoute
}

Jump to

Keyboard shortcuts

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