web

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWebServer

func BuildWebServer(db string, daoType int, statisticsDuration time.Duration) (*negroni.Negroni, error)

BuildWebServer constructs a new web server with the right DAO and spirits handler

Types

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

Route is a structure of Route

type Router

type Router struct {
	*mux.Router
}

Router is the struct use for routing

func NewRouter

func NewRouter(handler *SpiritHandler) *Router

NewRouter creates a new router instance

type SpiritHandler

type SpiritHandler struct {
	Routes []Route
	Prefix string
	// contains filtered or unexported fields
}

SpiritHandler is a handler of spirits

func NewSpiritHandler

func NewSpiritHandler(spiritDAO dao.SpiritDAO) *SpiritHandler

NewSpiritHandler creates a new spirit handler to manage spirits

func (*SpiritHandler) Create

func (sh *SpiritHandler) Create(w http.ResponseWriter, r *http.Request)

Create create an entity

func (*SpiritHandler) Delete

func (sh *SpiritHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete delete an entity by id

func (*SpiritHandler) Get

func (sh *SpiritHandler) Get(w http.ResponseWriter, r *http.Request)

Get retrieve an entity by id

func (*SpiritHandler) GetAll

func (sh *SpiritHandler) GetAll(w http.ResponseWriter, r *http.Request)

GetAll retrieve all entities with optional paging of items (start / end are item counts 50 to 100 for example)

func (*SpiritHandler) Update

func (sh *SpiritHandler) Update(w http.ResponseWriter, r *http.Request)

Update update an entity by id

type StatisticsMiddleware

type StatisticsMiddleware struct {
	Stat *utils.Statistics
}

StatisticsMiddleware is the middleware to record request statistics

func NewStatisticsMiddleware

func NewStatisticsMiddleware(duration time.Duration) *StatisticsMiddleware

NewStatisticsMiddleware creates a new statistics middleware

func (*StatisticsMiddleware) ServeHTTP

func (sm *StatisticsMiddleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Jump to

Keyboard shortcuts

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