1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

add example for #1601

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-22 03:21:44 +03:00
parent e41e861c4c
commit a018ba9b0a
12 changed files with 247 additions and 4 deletions

View File

@@ -17,12 +17,14 @@ import (
func main() {
app := iris.New()
idleConnsClosed := make(chan struct{})
iris.RegisterOnInterrupt(func() {
timeout := 10 * time.Second
ctx, cancel := stdContext.WithTimeout(stdContext.Background(), timeout)
defer cancel()
// close all hosts
app.Shutdown(ctx)
close(idleConnsClosed)
})
app.Get("/", func(ctx iris.Context) {
@@ -30,5 +32,6 @@ func main() {
})
// http://localhost:8080
app.Listen(":8080", iris.WithoutInterruptHandler)
app.Listen(":8080", iris.WithoutInterruptHandler, iris.WithoutServerError(iris.ErrServerClosed))
<-idleConnsClosed
}