server

package
v0.0.0-...-1979335 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Failure

func Failure(w http.ResponseWriter, status int, err ErrorMessage)

Failure response

func FailureFromError

func FailureFromError(w http.ResponseWriter, status int, err error)

FailureFromError write ErrorMessage from error

func JSON

func JSON(w http.ResponseWriter, code int, body interface{})

JSON response

func NotFoundFailure

func NotFoundFailure(w http.ResponseWriter, r *http.Request)

NotFoundFailure response

Types

type Controller

type Controller interface {
	Mount(r *Router)
}

type ErrorMessage

type ErrorMessage struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorMessage struct

func (ErrorMessage) Error

func (e ErrorMessage) Error() string

func (ErrorMessage) GetCode

func (e ErrorMessage) GetCode() int

func (ErrorMessage) GetMessage

func (e ErrorMessage) GetMessage() string

type ErrorMessageInterface

type ErrorMessageInterface interface {
	GetCode() int
	GetMessage() string
	Error() string
}

ErrorMessageInterface interface

type ErrorResponse

type ErrorResponse struct {
	Error ErrorMessage `json:"error"`
}

type HealthCheckHandler

type HealthCheckHandler func(context.Context) bool

HealthCheckHandler type

type HealthCheckResponse

type HealthCheckResponse struct {
	Status   bool            `json:"status"`
	Services map[string]bool `json:"services"`
}

HealthCheckResponse struct

type Router

type Router struct {
	*mux.Router
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

NewRouter constructor

func (*Router) AddController

func (r *Router) AddController(controller Controller)

func (*Router) AddHealthCheck

func (r *Router) AddHealthCheck(name string, handle HealthCheckHandler) error

AddHealthCheck handler

func (*Router) AddPrefixRoute

func (r *Router) AddPrefixRoute(prefix string, handler http.Handler) *mux.Route

func (*Router) AddPrefixRouteFunc

func (r *Router) AddPrefixRouteFunc(prefix string, handler http.HandlerFunc) *mux.Route

func (*Router) AddRoute

func (r *Router) AddRoute(path string, handler http.Handler) *mux.Route

func (*Router) AddRouteFunc

func (r *Router) AddRouteFunc(path string, handler http.HandlerFunc) *mux.Route

func (*Router) EnableHealthCheck

func (r *Router) EnableHealthCheck()

EnableHealthCheck endpoint

func (*Router) Use

func (r *Router) Use(middleware ...alice.Constructor)

Jump to

Keyboard shortcuts

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