Merge branch 'master' into fix-http

This commit is contained in:
Bo-Yi Wu 2017-08-16 09:44:33 +08:00 committed by GitHub
commit c7743e32b3
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.
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
// 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)
defer func() { debugPrintError(err) }()

View File

@ -102,7 +102,7 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
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"),
statusColor, statusCode, reset,
latency,

View File

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