controller

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: MIT Imports: 3 Imported by: 0

README

Controller

Base Json controller meant to be used within a Gorilla Mux Router

Run tests

go test -v ./...

Documentation

Index

Constants

View Source
const (
	DBErr   ErrorCode = "db_err"
	JSONErr           = "json_err"
	HTTPErr           = "http_err"
	GenErr            = "gen_err"
)

Variables

This section is empty.

Functions

func PanicBadRequest

func PanicBadRequest(code ErrorCode, msg string)

func PanicConflict

func PanicConflict(code ErrorCode, msg string)

func PanicInternalError

func PanicInternalError(code ErrorCode, msg string)

func PanicNotFound

func PanicNotFound(code ErrorCode, msg string)

Types

type ErrorCode

type ErrorCode string

swagger:model errorCode

type ErrorResponse

type ErrorResponse struct {
	// in: body
	Status int       `json:"-"`
	Code   ErrorCode `json:"error_code"`
	Msg    string    `json:"error_msg"`
}

swagger:model errorResponse

type Json

type Json struct {
	SetNoCacheHeaders bool
}

func (*Json) Handle

func (c *Json) Handle(w http.ResponseWriter, r *http.Request, handler RequestHandler)

func (*Json) ParseJsonBody

func (c *Json) ParseJsonBody(r *http.Request, v interface{})

type RequestHandler

type RequestHandler func() (status int, response interface{})

Jump to

Keyboard shortcuts

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