controller

package
v0.0.0-...-9b39c5b Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}

Functions

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

func ErrRender

func ErrRender(err error) render.Renderer

func LineCtx

func LineCtx(next http.Handler) http.Handler

LineCtx

func NewDocksListResponse

func NewDocksListResponse(docks []*entities.Dock) []render.Renderer

func NewFerriesListResponse

func NewFerriesListResponse(ferries []*entities.Ferry) []render.Renderer

func NewLinesListResponse

func NewLinesListResponse(lines []*entities.Line) []render.Renderer

func NewRoutesListResponse

func NewRoutesListResponse(routes []*entities.Route) []render.Renderer

func Router

func Router() http.Handler

Router is the default controller that has the routes for the application.

Types

type DockListResponse

type DockListResponse []*DockResponse

type DockResponse

type DockResponse struct {
	*entities.Dock
}

func NewDockResponse

func NewDockResponse(dock *entities.Dock) *DockResponse

func (*DockResponse) Render

func (rd *DockResponse) Render(w http.ResponseWriter, r *http.Request) error

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse defines a struct for the error responses.

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

type FerryListResponse

type FerryListResponse []*FerryResponse

type FerryResponse

type FerryResponse struct {
	*entities.Ferry
}

func NewFerryResponse

func NewFerryResponse(ferry *entities.Ferry) *FerryResponse

func (*FerryResponse) Render

func (rd *FerryResponse) Render(w http.ResponseWriter, r *http.Request) error

type LineAPIResponse

type LineAPIResponse struct {
	Data []*entities.Line
}

type LineListResponse

type LineListResponse []*LineResponse

type LineResponse

type LineResponse struct {
	*entities.Line
}

func NewLineResponse

func NewLineResponse(line *entities.Line) *LineResponse

func (*LineResponse) Render

func (rd *LineResponse) Render(w http.ResponseWriter, r *http.Request) error

type NextDepartureResponse

type NextDepartureResponse struct {
	NextDepartureTime      time.Time `json:"next_departure_time"`
	MinutesBeforeDeparture string    `json:"minutes_before_departure"`
}

func NewNextDepartureResponse

func NewNextDepartureResponse(nextdep *time.Time, d time.Duration) *NextDepartureResponse

func (*NextDepartureResponse) Render

type RouteListResponse

type RouteListResponse []*RouteResponse

type RouteResponse

type RouteResponse struct {
	*entities.Route
}

func NewRouteResponse

func NewRouteResponse(route *entities.Route) *RouteResponse

func (*RouteResponse) Render

func (rd *RouteResponse) Render(w http.ResponseWriter, r *http.Request) error

Jump to

Keyboard shortcuts

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