mirror of https://github.com/gin-gonic/gin.git
Cosmetic changes
This commit is contained in:
parent
b690611c38
commit
d6771dc4a5
|
@ -184,25 +184,22 @@ func (c *Context) ParamValue(key string) (va string) {
|
||||||
func (c *Context) DefaultPostFormValue(key, defaultValue string) string {
|
func (c *Context) DefaultPostFormValue(key, defaultValue string) string {
|
||||||
if va, ok := c.postFormValue(key); ok {
|
if va, ok := c.postFormValue(key); ok {
|
||||||
return va
|
return va
|
||||||
} else {
|
|
||||||
return defaultValue
|
|
||||||
}
|
}
|
||||||
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) DefaultFormValue(key, defaultValue string) string {
|
func (c *Context) DefaultFormValue(key, defaultValue string) string {
|
||||||
if va, ok := c.formValue(key); ok {
|
if va, ok := c.formValue(key); ok {
|
||||||
return va
|
return va
|
||||||
} else {
|
|
||||||
return defaultValue
|
|
||||||
}
|
}
|
||||||
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) DefaultParamValue(key, defaultValue string) string {
|
func (c *Context) DefaultParamValue(key, defaultValue string) string {
|
||||||
if va, ok := c.paramValue(key); ok {
|
if va, ok := c.paramValue(key); ok {
|
||||||
return va
|
return va
|
||||||
} else {
|
|
||||||
return defaultValue
|
|
||||||
}
|
}
|
||||||
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) paramValue(key string) (string, bool) {
|
func (c *Context) paramValue(key string) (string, bool) {
|
||||||
|
|
22
logger.go
22
logger.go
|
@ -75,11 +75,11 @@ func LoggerWithFile(out io.Writer) HandlerFunc {
|
||||||
|
|
||||||
func colorForStatus(code int) string {
|
func colorForStatus(code int) string {
|
||||||
switch {
|
switch {
|
||||||
case code >= 200 && code <= 299:
|
case code >= 200 && code < 300:
|
||||||
return green
|
return green
|
||||||
case code >= 300 && code <= 399:
|
case code >= 300 && code < 400:
|
||||||
return white
|
return white
|
||||||
case code >= 400 && code <= 499:
|
case code >= 400 && code < 500:
|
||||||
return yellow
|
return yellow
|
||||||
default:
|
default:
|
||||||
return red
|
return red
|
||||||
|
@ -87,20 +87,20 @@ func colorForStatus(code int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func colorForMethod(method string) string {
|
func colorForMethod(method string) string {
|
||||||
switch {
|
switch method {
|
||||||
case method == "GET":
|
case "GET":
|
||||||
return blue
|
return blue
|
||||||
case method == "POST":
|
case "POST":
|
||||||
return cyan
|
return cyan
|
||||||
case method == "PUT":
|
case "PUT":
|
||||||
return yellow
|
return yellow
|
||||||
case method == "DELETE":
|
case "DELETE":
|
||||||
return red
|
return red
|
||||||
case method == "PATCH":
|
case "PATCH":
|
||||||
return green
|
return green
|
||||||
case method == "HEAD":
|
case "HEAD":
|
||||||
return magenta
|
return magenta
|
||||||
case method == "OPTIONS":
|
case "OPTIONS":
|
||||||
return white
|
return white
|
||||||
default:
|
default:
|
||||||
return reset
|
return reset
|
||||||
|
|
|
@ -13,6 +13,9 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO unit tests
|
||||||
|
// test errors
|
||||||
|
|
||||||
func TestRenderJSON(t *testing.T) {
|
func TestRenderJSON(t *testing.T) {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
w2 := httptest.NewRecorder()
|
w2 := httptest.NewRecorder()
|
||||||
|
|
Loading…
Reference in New Issue