Skip to content

Commit

Permalink
Merge branch 'master' into new_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
vkd committed Feb 22, 2019
2 parents 244061c + 184661c commit e47300c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func (engine *Engine) RunUnix(file string) (err error) {
return
}
defer listener.Close()
os.Chmod(file, 0777)
err = http.Serve(listener, engine)
return
}
Expand Down
4 changes: 4 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type LogFormatterParams struct {
ErrorMessage string
// IsTerm shows whether does gin's output descriptor refers to a terminal.
IsTerm bool
// BodySize is the size of the Response Body
BodySize int
}

// defaultLogFormatter is the default log format function Logger middleware uses.
Expand Down Expand Up @@ -191,6 +193,8 @@ func LoggerWithConfig(conf LoggerConfig) HandlerFunc {
param.StatusCode = c.Writer.Status()
param.ErrorMessage = c.Errors.ByType(ErrorTypePrivate).String()

param.BodySize = c.Writer.Size()

if raw != "" {
path = path + "?" + raw
}
Expand Down
6 changes: 3 additions & 3 deletions mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/gin-gonic/gin/binding"
)

// ENV_GIN_MODE indicates environment name for gin mode.
const ENV_GIN_MODE = "GIN_MODE"
// EnvGinMode indicates environment name for gin mode.
const EnvGinMode = "GIN_MODE"

const (
// DebugMode indicates gin mode is debug.
Expand Down Expand Up @@ -44,7 +44,7 @@ var ginMode = debugCode
var modeName = DebugMode

func init() {
mode := os.Getenv(ENV_GIN_MODE)
mode := os.Getenv(EnvGinMode)
SetMode(mode)
}

Expand Down
4 changes: 2 additions & 2 deletions mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
)

func init() {
os.Setenv(ENV_GIN_MODE, TestMode)
os.Setenv(EnvGinMode, TestMode)
}

func TestSetMode(t *testing.T) {
assert.Equal(t, testCode, ginMode)
assert.Equal(t, TestMode, Mode())
os.Unsetenv(ENV_GIN_MODE)
os.Unsetenv(EnvGinMode)

SetMode("")
assert.Equal(t, debugCode, ginMode)
Expand Down

0 comments on commit e47300c

Please sign in to comment.