mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 03:41:28 +00:00
Merge pull request #2940 from BorisBorshevsky/golint
fix golint comments
This commit is contained in:
commit
9710d9e961
1
app.go
1
app.go
@ -55,6 +55,7 @@ func NewApp() *App {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MiddleWare function for http.Handler
|
||||||
type MiddleWare func(http.Handler) http.Handler
|
type MiddleWare func(http.Handler) http.Handler
|
||||||
|
|
||||||
// Run beego application.
|
// Run beego application.
|
||||||
|
1
beego.go
1
beego.go
@ -67,6 +67,7 @@ func Run(params ...string) {
|
|||||||
BeeApp.Run()
|
BeeApp.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunWithMiddleWares Run beego application with middlewares.
|
||||||
func RunWithMiddleWares(addr string, mws ...MiddleWare) {
|
func RunWithMiddleWares(addr string, mws ...MiddleWare) {
|
||||||
initBeforeHTTPRun()
|
initBeforeHTTPRun()
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error) {
|
|||||||
return srv.Serve()
|
return srv.Serve()
|
||||||
}
|
}
|
||||||
|
|
||||||
//ListenAndServeMutualTLS
|
// ListenAndServeMutualTLS listens on the TCP network address srv.Addr and then calls
|
||||||
|
// Serve to handle requests on incoming mutual TLS connections.
|
||||||
func (srv *Server) ListenAndServeMutualTLS(certFile, keyFile, trustFile string) (err error) {
|
func (srv *Server) ListenAndServeMutualTLS(certFile, keyFile, trustFile string) (err error) {
|
||||||
addr := srv.Addr
|
addr := srv.Addr
|
||||||
if addr == "" {
|
if addr == "" {
|
||||||
|
@ -27,6 +27,7 @@ const (
|
|||||||
jsonFormat = "JSON_FORMAT"
|
jsonFormat = "JSON_FORMAT"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AccessLogRecord struct for holding access log data.
|
||||||
type AccessLogRecord struct {
|
type AccessLogRecord struct {
|
||||||
RemoteAddr string `json:"remote_addr"`
|
RemoteAddr string `json:"remote_addr"`
|
||||||
RequestTime time.Time `json:"request_time"`
|
RequestTime time.Time `json:"request_time"`
|
||||||
@ -37,8 +38,8 @@ type AccessLogRecord struct {
|
|||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
BodyBytesSent int64 `json:"body_bytes_sent"`
|
BodyBytesSent int64 `json:"body_bytes_sent"`
|
||||||
ElapsedTime time.Duration `json:"elapsed_time"`
|
ElapsedTime time.Duration `json:"elapsed_time"`
|
||||||
HttpReferrer string `json:"http_referrer"`
|
HTTPReferrer string `json:"http_referrer"`
|
||||||
HttpUserAgent string `json:"http_user_agent"`
|
HTTPUserAgent string `json:"http_user_agent"`
|
||||||
RemoteUser string `json:"remote_user"`
|
RemoteUser string `json:"remote_user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +61,7 @@ func disableEscapeHTML(i interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AccessLog - Format and print access log.
|
||||||
func AccessLog(r *AccessLogRecord, format string) {
|
func AccessLog(r *AccessLogRecord, format string) {
|
||||||
var msg string
|
var msg string
|
||||||
|
|
||||||
@ -68,7 +70,7 @@ func AccessLog(r *AccessLogRecord, format string) {
|
|||||||
case apacheFormat:
|
case apacheFormat:
|
||||||
timeFormatted := r.RequestTime.Format("02/Jan/2006 03:04:05")
|
timeFormatted := r.RequestTime.Format("02/Jan/2006 03:04:05")
|
||||||
msg = fmt.Sprintf(apacheFormatPattern, r.RemoteAddr, timeFormatted, r.Request, r.Status, r.BodyBytesSent,
|
msg = fmt.Sprintf(apacheFormatPattern, r.RemoteAddr, timeFormatted, r.Request, r.Status, r.BodyBytesSent,
|
||||||
r.ElapsedTime.Seconds(), r.HttpReferrer, r.HttpUserAgent)
|
r.ElapsedTime.Seconds(), r.HTTPReferrer, r.HTTPUserAgent)
|
||||||
case jsonFormat:
|
case jsonFormat:
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
|
@ -915,8 +915,8 @@ Admin:
|
|||||||
Host: r.Host,
|
Host: r.Host,
|
||||||
Status: statusCode,
|
Status: statusCode,
|
||||||
ElapsedTime: timeDur,
|
ElapsedTime: timeDur,
|
||||||
HttpReferrer: r.Header.Get("Referer"),
|
HTTPReferrer: r.Header.Get("Referer"),
|
||||||
HttpUserAgent: r.Header.Get("User-Agent"),
|
HTTPUserAgent: r.Header.Get("User-Agent"),
|
||||||
RemoteUser: r.Header.Get("Remote-User"),
|
RemoteUser: r.Header.Get("Remote-User"),
|
||||||
BodyBytesSent: 0, //@todo this one is missing!
|
BodyBytesSent: 0, //@todo this one is missing!
|
||||||
}
|
}
|
||||||
|
@ -219,9 +219,8 @@ func BuildTemplate(dir string, files ...string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("parse template err:", file, err)
|
logs.Error("parse template err:", file, err)
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
beeTemplates[file] = t
|
|
||||||
}
|
}
|
||||||
|
beeTemplates[file] = t
|
||||||
templatesLock.Unlock()
|
templatesLock.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func (tc *TestPostUnregController) GetFixedLevel2() {
|
|||||||
// should remain intact, and continue to serve the original content.
|
// should remain intact, and continue to serve the original content.
|
||||||
func TestUnregisterFixedRouteRoot(t *testing.T) {
|
func TestUnregisterFixedRouteRoot(t *testing.T) {
|
||||||
|
|
||||||
var method string = "GET"
|
var method = "GET"
|
||||||
|
|
||||||
handler := NewControllerRegister()
|
handler := NewControllerRegister()
|
||||||
handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot")
|
handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot")
|
||||||
@ -114,7 +114,7 @@ func TestUnregisterFixedRouteRoot(t *testing.T) {
|
|||||||
// should remain intact, and continue to serve the original content.
|
// should remain intact, and continue to serve the original content.
|
||||||
func TestUnregisterFixedRouteLevel1(t *testing.T) {
|
func TestUnregisterFixedRouteLevel1(t *testing.T) {
|
||||||
|
|
||||||
var method string = "GET"
|
var method = "GET"
|
||||||
|
|
||||||
handler := NewControllerRegister()
|
handler := NewControllerRegister()
|
||||||
handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot")
|
handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot")
|
||||||
@ -164,7 +164,7 @@ func TestUnregisterFixedRouteLevel1(t *testing.T) {
|
|||||||
// should remain intact, and continue to serve the original content.
|
// should remain intact, and continue to serve the original content.
|
||||||
func TestUnregisterFixedRouteLevel2(t *testing.T) {
|
func TestUnregisterFixedRouteLevel2(t *testing.T) {
|
||||||
|
|
||||||
var method string = "GET"
|
var method = "GET"
|
||||||
|
|
||||||
handler := NewControllerRegister()
|
handler := NewControllerRegister()
|
||||||
handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot")
|
handler.Add("/", &TestPreUnregController{}, "get:GetFixedRoot")
|
||||||
|
@ -278,7 +278,7 @@ func (v *Validation) apply(chk Validator, obj interface{}) *Result {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add independent error message for key
|
// AddError adds independent error message for the provided key
|
||||||
func (v *Validation) AddError(key, message string) {
|
func (v *Validation) AddError(key, message string) {
|
||||||
Name := key
|
Name := key
|
||||||
Field := ""
|
Field := ""
|
||||||
|
Loading…
Reference in New Issue
Block a user