mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
Merge branch 'master' into doc
This commit is contained in:
commit
0d7bc58ca3
2
gin.go
2
gin.go
@ -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) }()
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user