gophers

package
v0.0.0-...-b9f111c Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2015 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(resp http.ResponseWriter, err string, code int)

func ErrorCalc

func ErrorCalc(resp http.ResponseWriter, err error)

func GetErrorHttpStatus

func GetErrorHttpStatus(err error) (string, int)

Checks for some known errors

func IsBadRequest

func IsBadRequest(err error) (bool, string)

func IsNotFoundError

func IsNotFoundError(err error) (bool, string)

func LoadFromJson

func LoadFromJson(req io.Reader, i interface{}) error

helper to load a provided pointer from json

func Marshal

func Marshal(resp http.ResponseWriter, statusCode int, result interface{})

Marshal any Marshalable type

func Recover

func Recover(g func(), message string)

Types

type CORSProvider

type CORSProvider struct {
	AllowOrigin string
}

CORSProvider can be used as middleware.

func (*CORSProvider) ServeHTTP

func (cp *CORSProvider) ServeHTTP(resp http.ResponseWriter, req *http.Request, next http.HandlerFunc)

type Config

type Config struct {
	DbServer    string
	DbName      string
	ServiceAddr string
}

func (*Config) GetDb

func (config *Config) GetDb() (*mgo.Session, *mgo.Database, error)

type ErrStruct

type ErrStruct struct {
	Message string `json:",omitempty"`
	Code    int    `json:",omitempty"`
}

type ErrorBadRequest

type ErrorBadRequest struct {
	Err    error  //default
	AltMsg string //alternate message
}

func (ErrorBadRequest) Error

func (e ErrorBadRequest) Error() string

type ErrorForbidden

type ErrorForbidden struct {
	Err    error  //default
	AltMsg string //alternate message
}

func (ErrorForbidden) Error

func (e ErrorForbidden) Error() string

type ErrorInternalServerError

type ErrorInternalServerError struct {
	Err    error  //default
	AltMsg string //alternate message
}

func (ErrorInternalServerError) Error

func (e ErrorInternalServerError) Error() string

type ErrorNotFound

type ErrorNotFound struct {
	Err    error  //default
	AltMsg string //alternate message
}

func (ErrorNotFound) Error

func (e ErrorNotFound) Error() string

type ErrorUnauthorized

type ErrorUnauthorized struct {
	Err    error  //default
	AltMsg string //alternate message
}

func (ErrorUnauthorized) Error

func (e ErrorUnauthorized) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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