Version: v0.0.0-...-57921cc Latest Latest

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

Go to latest
Published: Feb 5, 2016 License: BSD-2-Clause Imports: 14 Imported by: 0



Package errors contains common business errors to be user all over the server.



View Source
const (
	DEFAULT_PORT    = ":8000"
	DEFAULT_TIMEOUT = 10 * time.Second
View Source
const (
	E_BAD_REQUEST string = "bad_request"
	E_NOT_FOUND   string = "not_found"


View Source
var (
	ErrNotFound = errors.New("The resource requested does not exist.")


func BadRequest

func BadRequest(rw http.ResponseWriter, body interface{})

func CreateEndpoint

func CreateEndpoint(feature features.Features) endpoint.Endpoint

func DeleteEndpoint

func DeleteEndpoint(feature features.Features) endpoint.Endpoint

func FindEndpoint

func FindEndpoint(feature features.Features) endpoint.Endpoint

func ListEndpoint

func ListEndpoint(feature features.Features) endpoint.Endpoint

func NotFound

func NotFound(rw http.ResponseWriter, body interface{})

func UpdateEndpoint

func UpdateEndpoint(feature features.Features) endpoint.Endpoint

func ValidateEndpoint

func ValidateEndpoint(feature features.Features) endpoint.Endpoint


type Api

type Api struct {
	// contains filtered or unexported fields

func NewApi

func NewApi(ng engine.Engine) *Api

func (*Api) Handler

func (api *Api) Handler() http.Handler

func (*Api) Run

func (api *Api) Run()

type CollectionSerializer

type CollectionSerializer struct {
	Items interface{} `json:"items"`
	Count int         `json:"item_count"`

func (*CollectionSerializer) Serializer

func (cs *CollectionSerializer) Serializer() string

type ErrorResponse

type ErrorResponse struct {
	Type        string `json:"error,omitempty"`
	Description string `json:"error_description,omitempty"`

func NewErrorResponse

func NewErrorResponse(errType, description string) ErrorResponse

func (ErrorResponse) Error

func (err ErrorResponse) Error() string

type HTTPResponse

type HTTPResponse struct {
	ContentType string      `json:"-"`
	StatusCode  int         `json:"-"`
	Body        interface{} `json:"body,omitempty"`

func (*HTTPResponse) ToJson

func (h *HTTPResponse) ToJson() []byte

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields

func NewNotFoundError

func NewNotFoundError(err error) NotFoundError

func (NotFoundError) Error

func (err NotFoundError) Error() string

type Router

type Router struct {
	// contains filtered or unexported fields

func NewRouter

func NewRouter() *Router

func (*Router) AddHandler

func (router *Router) AddHandler(args RouterArguments)

func (*Router) AddMiddleware

func (router *Router) AddMiddleware(pathPrefix string, h http.Handler)

func (*Router) AddSubrouter

func (router *Router) AddSubrouter(pathPrefix string) *mux.Router

func (*Router) Handler

func (router *Router) Handler() http.Handler

func (*Router) NotFoundHandler

func (router *Router) NotFoundHandler(h http.Handler)

func (*Router) Subrouter

func (router *Router) Subrouter(pathPrefix string) *mux.Router

type RouterArguments

type RouterArguments struct {
	Handler       http.HandlerFunc
	HandlerNormal http.Handler
	Path          string
	PathPrefix    string
	Methods       []string


Path Synopsis

Jump to

Keyboard shortcuts

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