From 688eb1281c6c027fbf44d9af9aea9abe32794d07 Mon Sep 17 00:00:00 2001 From: Dang Nguyen Date: Sat, 2 Mar 2019 15:04:21 +0700 Subject: [PATCH 1/4] update examples link in README (#1789) --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a4ced64e..6cb0e78c 100644 --- a/README.md +++ b/README.md @@ -359,7 +359,7 @@ ids: map[b:hello a:1234], names: map[second:tianou first:thinkerou] #### Single file -References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail [example code](examples/upload-file/single). +References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail [example code](https://github.com/gin-gonic/examples/tree/master/upload-file/single). `file.Filename` **SHOULD NOT** be trusted. See [`Content-Disposition` on MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Directives) and [#1693](https://github.com/gin-gonic/gin/issues/1693) @@ -394,7 +394,7 @@ curl -X POST http://localhost:8080/upload \ #### Multiple files -See the detail [example code](examples/upload-file/multiple). +See the detail [example code](https://github.com/gin-gonic/examples/tree/master/upload-file/multiple). ```go func main() { @@ -726,7 +726,7 @@ When running the above example using the above the `curl` command, it returns er ### Custom Validators -It is also possible to register custom validators. See the [example code](examples/custom-validation/server.go). +It is also possible to register custom validators. See the [example code](https://github.com/gin-gonic/examples/tree/master/custom-validation/server.go). ```go package main @@ -790,7 +790,7 @@ $ curl "localhost:8085/bookable?check_in=2018-03-08&check_out=2018-03-09" ``` [Struct level validations](https://github.com/go-playground/validator/releases/tag/v8.7) can also be registered this way. -See the [struct-lvl-validation example](examples/struct-lvl-validations) to learn more. +See the [struct-lvl-validation example](https://github.com/gin-gonic/examples/tree/master/struct-lvl-validations) to learn more. ### Only Bind Query String @@ -1280,7 +1280,7 @@ You may use custom delims #### Custom Template Funcs -See the detail [example code](examples/template). +See the detail [example code](https://github.com/gin-gonic/examples/tree/master/template). main.go @@ -1654,7 +1654,7 @@ An alternative to endless: * [graceful](https://github.com/tylerb/graceful): Graceful is a Go package enabling graceful shutdown of an http.Handler server. * [grace](https://github.com/facebookgo/grace): Graceful restart & zero downtime deploy for Go servers. -If you are using Go 1.8, you may not need to use this library! Consider using http.Server's built-in [Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown) method for graceful shutdowns. See the full [graceful-shutdown](./examples/graceful-shutdown) example with gin. +If you are using Go 1.8, you may not need to use this library! Consider using http.Server's built-in [Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown) method for graceful shutdowns. See the full [graceful-shutdown](https://github.com/gin-gonic/examples/tree/master/graceful-shutdown) example with gin. ```go // +build go1.8 @@ -1758,7 +1758,7 @@ func loadTemplate() (*template.Template, error) { } ``` -See a complete example in the `examples/assets-in-binary` directory. +See a complete example in the `https://github.com/gin-gonic/examples/tree/master/assets-in-binary` directory. ### Bind form-data request with custom struct From 8c8002d7449979ab65d22794be159751dbc1c20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=AC=A7?= Date: Sat, 2 Mar 2019 19:21:10 +0800 Subject: [PATCH 2/4] chore: add examples repo link to README (#1788) --- README.md | 2 ++ examples/README.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6cb0e78c..20e3e58d 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,8 @@ $ go build -tags=jsoniter . ## API Examples +You can find a number of ready-to-run examples at [Gin examples repository](https://github.com/gin-gonic/examples). + ### Using GET, POST, PUT, PATCH, DELETE and OPTIONS ```go diff --git a/examples/README.md b/examples/README.md index 4b3b718c..b02deae4 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,3 +1,3 @@ # Gin Examples -## TODO +⚠️ **NOTICE:** All gin examples has moved as alone repository to [here](https://github.com/gin-gonic/examples). From 3b84a430d0a6307b1f788952520db268bc3effe4 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sat, 2 Mar 2019 20:19:42 +0800 Subject: [PATCH 3/4] Drone switch from gin to go-chi in 1.0 version. (#1790) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 20e3e58d..a22440f9 100644 --- a/README.md +++ b/README.md @@ -2082,7 +2082,6 @@ func TestPingRoute(t *testing.T) { Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framework. -* [drone](https://github.com/drone/drone): Drone is a Continuous Delivery platform built on Docker, written in Go. * [gorush](https://github.com/appleboy/gorush): A push notification server written in Go. * [fnproject](https://github.com/fnproject/fn): The container native, cloud agnostic serverless platform. * [photoprism](https://github.com/photoprism/photoprism): Personal photo management powered by Go and Google TensorFlow. From 893c6cae07ef564cbdd2796589c449dd2ac87d21 Mon Sep 17 00:00:00 2001 From: Daniel Krom Date: Sat, 2 Mar 2019 17:07:37 +0200 Subject: [PATCH 4/4] Added stream flag indicates if client disconnected in middle of streaming (#1252) --- context.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/context.go b/context.go index e9735d28..5dc7f8a0 100644 --- a/context.go +++ b/context.go @@ -896,19 +896,20 @@ func (c *Context) SSEvent(name string, message interface{}) { }) } -// Stream sends a streaming response. -func (c *Context) Stream(step func(w io.Writer) bool) { +// Stream sends a streaming response and returns a boolean +// indicates "Is client disconnected in middle of stream" +func (c *Context) Stream(step func(w io.Writer) bool) bool { w := c.Writer clientGone := w.CloseNotify() for { select { case <-clientGone: - return + return true default: keepOpen := step(w) w.Flush() if !keepOpen { - return + return false } } }