1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-05 00:58:47 +02:00

First commit to v3, #665

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-09-22 22:53:44 -07:00
parent 04f45046b1
commit 2aec0353f5
66 changed files with 656 additions and 3264 deletions

View File

@ -117,16 +117,16 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
case "time_rfc3339":
return w.Write([]byte(time.Now().Format(time.RFC3339)))
case "remote_ip":
ra := req.RealIP()
ra := c.RealIP()
return w.Write([]byte(ra))
case "host":
return w.Write([]byte(req.Host()))
return w.Write([]byte(req.Host))
case "uri":
return w.Write([]byte(req.URI()))
return w.Write([]byte(req.RequestURI))
case "method":
return w.Write([]byte(req.Method()))
return w.Write([]byte(req.Method))
case "path":
p := req.URL().Path()
p := req.URL.Path
if p == "" {
p = "/"
}
@ -136,7 +136,7 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
case "user_agent":
return w.Write([]byte(req.UserAgent()))
case "status":
n := res.Status()
n := res.Status
s := config.color.Green(n)
switch {
case n >= 500:
@ -153,13 +153,13 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
case "latency_human":
return w.Write([]byte(stop.Sub(start).String()))
case "bytes_in":
b := req.Header().Get(echo.HeaderContentLength)
b := req.Header.Get(echo.HeaderContentLength)
if b == "" {
b = "0"
}
return w.Write([]byte(b))
case "bytes_out":
return w.Write([]byte(strconv.FormatInt(res.Size(), 10)))
return w.Write([]byte(strconv.FormatInt(res.Size, 10)))
}
return 0, nil
})