middleware

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2014 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AppName string
	VERSION string
)
View Source
var ErrorMaps map[string]http.HandlerFunc

map of http handlers for each error string.

View Source
var HTTPExceptionMaps map[int]HTTPException

map of http exceptions for each http status code int. defined 400,401,403,404,405,500,502,503 and 504 default.

Functions

func Errorhandler

func Errorhandler(err string, h http.HandlerFunc)

add http handler for given error string.

func Exception

func Exception(errcode string, w http.ResponseWriter, r *http.Request, msg string)

show error string as simple text message. if error string is empty, show 500 error as default.

func Forbidden

func Forbidden(rw http.ResponseWriter, r *http.Request)

show 403 forbidden error.

func InternalServerError

func InternalServerError(rw http.ResponseWriter, r *http.Request)

show 500 internal server error.

func NotFound

func NotFound(rw http.ResponseWriter, r *http.Request)

show 404 notfound error.

func RegisterErrorHandler

func RegisterErrorHandler()

register default error http handlers, 404,401,403,500 and 503.

func ServiceUnavailable

func ServiceUnavailable(rw http.ResponseWriter, r *http.Request)

show 503 service unavailable error.

func ShowErr

func ShowErr(err interface{}, rw http.ResponseWriter, r *http.Request, Stack string)

render default application error page with error and stack string.

func SimpleServerError

func SimpleServerError(rw http.ResponseWriter, r *http.Request)

show 500 internal error with simple text string.

func Unauthorized

func Unauthorized(rw http.ResponseWriter, r *http.Request)

show 401 unauthorized error.

Types

type HTTPException

type HTTPException struct {
	StatusCode  int // http status code 4xx, 5xx
	Description string
}

http exceptions

func (*HTTPException) Error

func (e *HTTPException) Error() string

return http exception error string, e.g. "400 Bad Request".

Jump to

Keyboard shortcuts

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