From 13ba260d7623aabef9ce6a423fb8017cd3411a90 Mon Sep 17 00:00:00 2001 From: shadrus Date: Mon, 5 Oct 2015 22:27:03 +0300 Subject: [PATCH 1/6] Wrong copy/paste TODO --- logger_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/logger_test.go b/logger_test.go index 267f9c5b..821fb9e7 100644 --- a/logger_test.go +++ b/logger_test.go @@ -12,12 +12,6 @@ import ( "github.com/stretchr/testify/assert" ) -//TODO -// func (engine *Engine) LoadHTMLGlob(pattern string) { -// func (engine *Engine) LoadHTMLFiles(files ...string) { -// func (engine *Engine) Run(addr string) error { -// func (engine *Engine) RunTLS(addr string, cert string, key string) error { - func init() { SetMode(TestMode) } From 1541a141ee497450a450a8ce44a9eb71b23996a8 Mon Sep 17 00:00:00 2001 From: Brian Wigginton Date: Tue, 27 Oct 2015 12:22:18 -0500 Subject: [PATCH 2/6] update docs for context.Abort The docs were a little unclear as to how to use Abort, and how it will affect the current handler. --- context.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/context.go b/context.go index b784c14b..ca868329 100644 --- a/context.go +++ b/context.go @@ -101,10 +101,10 @@ func (c *Context) IsAborted() bool { return c.index >= abortIndex } -// Abort stops the system to continue calling the pending handlers in the chain. -// Let's say you have an authorization middleware that validates if the request is authorized -// if the authorization fails (the password does not match). This method (Abort()) should be called -// in order to stop the execution of the actual handler. +// Abort prevents pending handlers from being called. Note that this will not stop the current execution context. +// Let's say you have an authorization middleware that validates that the current request is authorized. If the +// authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers +// for this request are not called. func (c *Context) Abort() { c.index = abortIndex } From 353fa14750af3091846047c0245f7bfc0450c7d3 Mon Sep 17 00:00:00 2001 From: Brian Wigginton Date: Tue, 27 Oct 2015 12:26:05 -0500 Subject: [PATCH 3/6] additional clarification --- context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context.go b/context.go index ca868329..7772b460 100644 --- a/context.go +++ b/context.go @@ -101,7 +101,7 @@ func (c *Context) IsAborted() bool { return c.index >= abortIndex } -// Abort prevents pending handlers from being called. Note that this will not stop the current execution context. +// Abort prevents pending handlers from being called. Note that this will not stop the current handler. // Let's say you have an authorization middleware that validates that the current request is authorized. If the // authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers // for this request are not called. From 23c01faeb3817216350cce83e9850cf9c25db948 Mon Sep 17 00:00:00 2001 From: Kyle Mcgill Date: Wed, 4 Nov 2015 21:03:57 +1300 Subject: [PATCH 4/6] undefinitely -> indefinitely It was bugging me :) --- gin.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gin.go b/gin.go index 3834d67e..6c36f985 100644 --- a/gin.go +++ b/gin.go @@ -227,7 +227,7 @@ func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo { // Run attaches the router to a http.Server and starts listening and serving HTTP requests. // It is a shortcut for http.ListenAndServe(addr, router) -// Note: this method will block the calling goroutine undefinitelly unless an error happens. +// Note: this method will block the calling goroutine indefinitely unless an error happens. func (engine *Engine) Run(addr ...string) (err error) { defer func() { debugPrintError(err) }() @@ -239,7 +239,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 undefinitelly 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) { debugPrint("Listening and serving HTTPS on %s\n", addr) defer func() { debugPrintError(err) }() @@ -250,7 +250,7 @@ func (engine *Engine) RunTLS(addr string, certFile string, keyFile string) (err // RunUnix attaches the router to a http.Server and starts listening and serving HTTP requests // through the specified unix socket (ie. a file). -// Note: this method will block the calling goroutine undefinitelly unless an error happens. +// Note: this method will block the calling goroutine indefinitely unless an error happens. func (engine *Engine) RunUnix(file string) (err error) { debugPrint("Listening and serving HTTP on unix:/%s", file) defer func() { debugPrintError(err) }() From 8b000c5a04845fbc6e6783083ec4bb39a006e1ed Mon Sep 17 00:00:00 2001 From: ZhiFeng Hu Date: Wed, 11 Nov 2015 10:27:36 +0800 Subject: [PATCH 5/6] Add document about graceful restart or stop I am looking for a long time , add this document will help who were looking for graceful restart/stop like me. Signed-off-by: ZhiFeng Hu --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index e83952d6..d8f44c22 100644 --- a/README.md +++ b/README.md @@ -609,3 +609,22 @@ func main() { s.ListenAndServe() } ``` + +#### Graceful restart or stop + +Do you want to graceful restart or stop your web server? +There be some ways. + +We can using fvbock/endless to replace the default ListenAndServe + +Refer the issue for more details: + +https://github.com/gin-gonic/gin/issues/296 + +```go +router := gin.Default() +router.GET("/", handler) +// [...] +endless.ListenAndServe(":4242", router) + +``` From c5c806d22d3f0d3f92c2a18c1351a24a677462e5 Mon Sep 17 00:00:00 2001 From: Josh Horowitz Date: Thu, 14 Jan 2016 15:58:17 -0500 Subject: [PATCH 6/6] Fixed typo. join -> john --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e83952d6..6af2d760 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ func main() { }) // However, this one will match /user/john/ and also /user/john/send - // If no other routers match /user/john, it will redirect to /user/join/ + // If no other routers match /user/john, it will redirect to /user/john/ router.GET("/user/:name/*action", func(c *gin.Context) { name := c.Param("name") action := c.Param("action")