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 ¶
- Variables
- func Errorhandler(err string, h http.HandlerFunc)
- func Exception(errcode string, w http.ResponseWriter, r *http.Request, msg string)
- func Forbidden(rw http.ResponseWriter, r *http.Request)
- func InternalServerError(rw http.ResponseWriter, r *http.Request)
- func NotFound(rw http.ResponseWriter, r *http.Request)
- func RegisterErrorHandler()
- func ServiceUnavailable(rw http.ResponseWriter, r *http.Request)
- func ShowErr(err interface{}, rw http.ResponseWriter, r *http.Request, Stack string)
- func SimpleServerError(rw http.ResponseWriter, r *http.Request)
- func Unauthorized(rw http.ResponseWriter, r *http.Request)
- type HTTPException
- type Translation
Constants ¶
This section is empty.
Variables ¶
var ( AppName string VERSION string )
var ErrorMaps map[string]http.HandlerFunc
map of http handlers for each error string.
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 ¶
show error string as simple text message. if error string is empty, show 500 error as default.
func InternalServerError ¶
func InternalServerError(rw http.ResponseWriter, r *http.Request)
show 500 internal server 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 ¶
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)