chore: use http.Status* instead of hard code (#1482)

This commit is contained in:
田欧
2018-08-14 09:51:56 +08:00
committed by Bo-Yi Wu
parent 8aef947f6e
commit f45c928a15
20 changed files with 209 additions and 192 deletions

View File

@ -7,6 +7,7 @@ package gin
import (
"fmt"
"io"
"net/http"
"os"
"time"
@ -118,11 +119,11 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
func colorForStatus(code int) string {
switch {
case code >= 200 && code < 300:
case code >= http.StatusOK && code < http.StatusMultipleChoices:
return green
case code >= 300 && code < 400:
case code >= http.StatusMultipleChoices && code < http.StatusBadRequest:
return white
case code >= 400 && code < 500:
case code >= http.StatusBadRequest && code < http.StatusInternalServerError:
return yellow
default:
return red