mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 19:30:54 +00:00
gofmt commented go files
This commit is contained in:
parent
b459cf2347
commit
ce332713c4
2
app.go
2
app.go
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/astaxie/beego/context"
|
"github.com/astaxie/beego/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FitlerFunc defines filter function type.
|
// FilterFunc defines filter function type.
|
||||||
type FilterFunc func(*context.Context)
|
type FilterFunc func(*context.Context)
|
||||||
|
|
||||||
// App defines beego application with a new PatternServeMux.
|
// App defines beego application with a new PatternServeMux.
|
||||||
|
80
config.go
80
config.go
@ -15,76 +15,76 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// beego application
|
// beego application
|
||||||
BeeApp *App
|
BeeApp *App
|
||||||
// application configurations
|
// application configurations
|
||||||
AppName string
|
AppName string
|
||||||
AppPath string
|
AppPath string
|
||||||
AppConfigPath string
|
AppConfigPath string
|
||||||
StaticDir map[string]string
|
StaticDir map[string]string
|
||||||
// template caching map
|
// template caching map
|
||||||
TemplateCache map[string]*template.Template
|
TemplateCache map[string]*template.Template
|
||||||
// files with should be compressed with gzip (.js,.css,etc)
|
// files with should be compressed with gzip (.js,.css,etc)
|
||||||
StaticExtensionsToGzip []string
|
StaticExtensionsToGzip []string
|
||||||
// http server configurations
|
// http server configurations
|
||||||
HttpAddr string
|
HttpAddr string
|
||||||
HttpPort int
|
HttpPort int
|
||||||
HttpTLS bool
|
HttpTLS bool
|
||||||
HttpCertFile string
|
HttpCertFile string
|
||||||
HttpKeyFile string
|
HttpKeyFile string
|
||||||
// flag of auto recover panic
|
// flag of auto recover panic
|
||||||
RecoverPanic bool
|
RecoverPanic bool
|
||||||
// flag of render template automatically
|
// flag of render template automatically
|
||||||
AutoRender bool
|
AutoRender bool
|
||||||
ViewsPath string
|
ViewsPath string
|
||||||
// run mode, "dev" or "prod"
|
// run mode, "dev" or "prod"
|
||||||
RunMode string
|
RunMode string
|
||||||
AppConfig config.ConfigContainer
|
AppConfig config.ConfigContainer
|
||||||
// global session mananger
|
// global session mananger
|
||||||
GlobalSessions *session.Manager
|
GlobalSessions *session.Manager
|
||||||
// flag of starting session auto. default is false.
|
// flag of starting session auto. default is false.
|
||||||
SessionOn bool
|
SessionOn bool
|
||||||
// default session provider, memory, mysql , redis ,etc.
|
// default session provider, memory, mysql , redis ,etc.
|
||||||
SessionProvider string
|
SessionProvider string
|
||||||
// the cookie name when saving session id into cookie.
|
// the cookie name when saving session id into cookie.
|
||||||
SessionName string
|
SessionName string
|
||||||
// session gc time for auto cleaning expired session.
|
// session gc time for auto cleaning expired session.
|
||||||
SessionGCMaxLifetime int64
|
SessionGCMaxLifetime int64
|
||||||
// if use mysql/redis/file provider, define save path to connection info.
|
// if use mysql/redis/file provider, define save path to connection info.
|
||||||
SessionSavePath string
|
SessionSavePath string
|
||||||
// session hash generation func.
|
// session hash generation func.
|
||||||
SessionHashFunc string
|
SessionHashFunc string
|
||||||
// session hash salt string.
|
// session hash salt string.
|
||||||
SessionHashKey string
|
SessionHashKey string
|
||||||
// the life time of session id in cookie.
|
// the life time of session id in cookie.
|
||||||
SessionCookieLifeTime int
|
SessionCookieLifeTime int
|
||||||
UseFcgi bool
|
UseFcgi bool
|
||||||
MaxMemory int64
|
MaxMemory int64
|
||||||
// flag of enable gzip
|
// flag of enable gzip
|
||||||
EnableGzip bool
|
EnableGzip bool
|
||||||
// flag of display directory index. default is false.
|
// flag of display directory index. default is false.
|
||||||
DirectoryIndex bool
|
DirectoryIndex bool
|
||||||
// flag of hot update checking in app self. default is false.
|
// flag of hot update checking in app self. default is false.
|
||||||
EnableHotUpdate bool
|
EnableHotUpdate bool
|
||||||
HttpServerTimeOut int64
|
HttpServerTimeOut int64
|
||||||
// flag of show errors in page. if true, show error and trace info in page rendered with error template.
|
// flag of show errors in page. if true, show error and trace info in page rendered with error template.
|
||||||
ErrorsShow bool
|
ErrorsShow bool
|
||||||
// xsrf hash salt string.
|
// xsrf hash salt string.
|
||||||
XSRFKEY string
|
XSRFKEY string
|
||||||
// flag of enable xsrf.
|
// flag of enable xsrf.
|
||||||
EnableXSRF bool
|
EnableXSRF bool
|
||||||
// the expiry of xsrf value.
|
// the expiry of xsrf value.
|
||||||
XSRFExpire int
|
XSRFExpire int
|
||||||
// flag of copy raw request body in context.
|
// flag of copy raw request body in context.
|
||||||
CopyRequestBody bool
|
CopyRequestBody bool
|
||||||
TemplateLeft string
|
TemplateLeft string
|
||||||
TemplateRight string
|
TemplateRight string
|
||||||
// beego server name exported in response header.
|
// beego server name exported in response header.
|
||||||
BeegoServerName string
|
BeegoServerName string
|
||||||
// flag of enable admin module to log every request info.
|
// flag of enable admin module to log every request info.
|
||||||
EnableAdmin bool
|
EnableAdmin bool
|
||||||
// http server configurations for admin module.
|
// http server configurations for admin module.
|
||||||
AdminHttpAddr string
|
AdminHttpAddr string
|
||||||
AdminHttpPort int
|
AdminHttpPort int
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -127,7 +127,7 @@ func init() {
|
|||||||
|
|
||||||
UseFcgi = false
|
UseFcgi = false
|
||||||
|
|
||||||
MaxMemory = 1<<26 //64MB
|
MaxMemory = 1 << 26 //64MB
|
||||||
|
|
||||||
EnableGzip = false
|
EnableGzip = false
|
||||||
|
|
||||||
|
@ -144,15 +144,15 @@ func (c *Controller) RenderBytes() ([]byte, error) {
|
|||||||
//if the controller has set layout, then first get the tplname's content set the content to the layout
|
//if the controller has set layout, then first get the tplname's content set the content to the layout
|
||||||
if c.Layout != "" {
|
if c.Layout != "" {
|
||||||
if c.TplNames == "" {
|
if c.TplNames == "" {
|
||||||
c.TplNames = strings.ToLower(c.controllerName)+"/"+strings.ToLower(c.actionName)+"." + c.TplExt
|
c.TplNames = strings.ToLower(c.controllerName) + "/" + strings.ToLower(c.actionName) + "." + c.TplExt
|
||||||
}
|
}
|
||||||
if RunMode == "dev" {
|
if RunMode == "dev" {
|
||||||
BuildTemplate(ViewsPath)
|
BuildTemplate(ViewsPath)
|
||||||
}
|
}
|
||||||
newbytes := bytes.NewBufferString("")
|
newbytes := bytes.NewBufferString("")
|
||||||
if _, ok := BeeTemplates[c.TplNames]; !ok {
|
if _, ok := BeeTemplates[c.TplNames]; !ok {
|
||||||
panic("can't find templatefile in the path:"+c.TplNames)
|
panic("can't find templatefile in the path:" + c.TplNames)
|
||||||
return []byte{}, errors.New("can't find templatefile in the path:"+c.TplNames)
|
return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
|
||||||
}
|
}
|
||||||
err := BeeTemplates[c.TplNames].ExecuteTemplate(newbytes, c.TplNames, c.Data)
|
err := BeeTemplates[c.TplNames].ExecuteTemplate(newbytes, c.TplNames, c.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -171,15 +171,15 @@ func (c *Controller) RenderBytes() ([]byte, error) {
|
|||||||
return icontent, nil
|
return icontent, nil
|
||||||
} else {
|
} else {
|
||||||
if c.TplNames == "" {
|
if c.TplNames == "" {
|
||||||
c.TplNames = strings.ToLower(c.controllerName)+"/"+strings.ToLower(c.actionName)+"." + c.TplExt
|
c.TplNames = strings.ToLower(c.controllerName) + "/" + strings.ToLower(c.actionName) + "." + c.TplExt
|
||||||
}
|
}
|
||||||
if RunMode == "dev" {
|
if RunMode == "dev" {
|
||||||
BuildTemplate(ViewsPath)
|
BuildTemplate(ViewsPath)
|
||||||
}
|
}
|
||||||
ibytes := bytes.NewBufferString("")
|
ibytes := bytes.NewBufferString("")
|
||||||
if _, ok := BeeTemplates[c.TplNames]; !ok {
|
if _, ok := BeeTemplates[c.TplNames]; !ok {
|
||||||
panic("can't find templatefile in the path:"+c.TplNames)
|
panic("can't find templatefile in the path:" + c.TplNames)
|
||||||
return []byte{}, errors.New("can't find templatefile in the path:"+c.TplNames)
|
return []byte{}, errors.New("can't find templatefile in the path:" + c.TplNames)
|
||||||
}
|
}
|
||||||
err := BeeTemplates[c.TplNames].ExecuteTemplate(ibytes, c.TplNames, c.Data)
|
err := BeeTemplates[c.TplNames].ExecuteTemplate(ibytes, c.TplNames, c.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -219,7 +219,7 @@ func (c *Controller) UrlFor(endpoint string, values ...string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if endpoint[0] == '.' {
|
if endpoint[0] == '.' {
|
||||||
return UrlFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name() + endpoint, values...)
|
return UrlFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name()+endpoint, values...)
|
||||||
} else {
|
} else {
|
||||||
return UrlFor(endpoint, values...)
|
return UrlFor(endpoint, values...)
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
f, err := os.OpenFile(tofile, os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0666)
|
f, err := os.OpenFile(tofile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -464,7 +464,7 @@ func (c *Controller) CheckXsrfCookie() bool {
|
|||||||
// XsrfFormHtml writes an input field contains xsrf token value.
|
// XsrfFormHtml writes an input field contains xsrf token value.
|
||||||
func (c *Controller) XsrfFormHtml() string {
|
func (c *Controller) XsrfFormHtml() string {
|
||||||
return "<input type=\"hidden\" name=\"_xsrf\" value=\"" +
|
return "<input type=\"hidden\" name=\"_xsrf\" value=\"" +
|
||||||
c._xsrf_token + "\"/>"
|
c._xsrf_token + "\"/>"
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetControllerAndAction gets the executing controller name and action name.
|
// GetControllerAndAction gets the executing controller name and action name.
|
||||||
|
Loading…
Reference in New Issue
Block a user