Merge branch 'master' into doc

This commit is contained in:
Bo-Yi Wu 2017-08-14 14:34:53 +08:00 committed by GitHub
commit 0d7bc58ca3
3 changed files with 15 additions and 15 deletions

2
gin.go
View File

@ -268,7 +268,7 @@ func (engine *Engine) Run(addr ...string) (err error) {
// RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests. // RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests.
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router) // It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
// Note: this method will block the calling goroutine indefinitely unless an error happens. // Note: this method will block the calling goroutine indefinitely unless an error happens.
func (engine *Engine) RunTLS(addr string, certFile string, keyFile string) (err error) { func (engine *Engine) RunTLS(addr, certFile, keyFile string) (err error) {
debugPrint("Listening and serving HTTPS on %s\n", addr) debugPrint("Listening and serving HTTPS on %s\n", addr)
defer func() { debugPrintError(err) }() defer func() { debugPrintError(err) }()

View File

@ -102,7 +102,7 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
path = path + "?" + raw path = path + "?" + raw
} }
fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %s %-7s %s\n%s", fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
end.Format("2006/01/02 - 15:04:05"), end.Format("2006/01/02 - 15:04:05"),
statusColor, statusCode, reset, statusColor, statusCode, reset,
latency, latency,

View File

@ -356,25 +356,25 @@ func TestRouterNotFound(t *testing.T) {
router.GET("/", func(c *Context) {}) router.GET("/", func(c *Context) {})
testRoutes := []struct { testRoutes := []struct {
route string route string
code int code int
header string location string
}{ }{
{"/path/", 301, "map[Location:[/path]]"}, // TSR -/ {"/path/", 301, "/path"}, // TSR -/
{"/dir", 301, "map[Location:[/dir/]]"}, // TSR +/ {"/dir", 301, "/dir/"}, // TSR +/
{"", 301, "map[Location:[/]]"}, // TSR +/ {"", 301, "/"}, // TSR +/
{"/PATH", 301, "map[Location:[/path]]"}, // Fixed Case {"/PATH", 301, "/path"}, // Fixed Case
{"/DIR/", 301, "map[Location:[/dir/]]"}, // Fixed Case {"/DIR/", 301, "/dir/"}, // Fixed Case
{"/PATH/", 301, "map[Location:[/path]]"}, // Fixed Case -/ {"/PATH/", 301, "/path"}, // Fixed Case -/
{"/DIR", 301, "map[Location:[/dir/]]"}, // Fixed Case +/ {"/DIR", 301, "/dir/"}, // Fixed Case +/
{"/../path", 301, "map[Location:[/path]]"}, // CleanPath {"/../path", 301, "/path"}, // CleanPath
{"/nope", 404, ""}, // NotFound {"/nope", 404, ""}, // NotFound
} }
for _, tr := range testRoutes { for _, tr := range testRoutes {
w := performRequest(router, "GET", tr.route) w := performRequest(router, "GET", tr.route)
assert.Equal(t, w.Code, tr.code) assert.Equal(t, w.Code, tr.code)
if w.Code != 404 { if w.Code != 404 {
assert.Equal(t, fmt.Sprint(w.Header()), tr.header) assert.Equal(t, fmt.Sprint(w.Header().Get("Location")), tr.location)
} }
} }