middleware

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2014 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Usage:

import "github.com/astaxie/beego/middleware"

I18N = middleware.NewLocale("conf/i18n.conf", beego.AppConfig.String("language"))

more docs: http://beego.me/docs/module/i18n.md

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".

type Translation added in v1.4.0

type Translation struct {
	CurrentLocal string
	Locales      map[string]map[string]string
	// contains filtered or unexported fields
}

func NewLocale added in v1.4.0

func NewLocale(filepath string, defaultlocal string) *Translation

func (*Translation) SetLocale added in v1.4.0

func (t *Translation) SetLocale(local string)

func (*Translation) Translate added in v1.4.0

func (t *Translation) Translate(key string, local string) string

Jump to

Keyboard shortcuts

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