mirror of
https://github.com/labstack/echo.git
synced 2025-04-19 12:12:51 +02:00
Example usage of echo with github.com/facebookgo/grace/gracehttp and github.com/tylerb/graceful
This commit is contained in:
parent
07c0cf21f0
commit
33eb3fb67b
20
examples/grace/server.go
Normal file
20
examples/grace/server.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/facebookgo/grace/gracehttp"
|
||||||
|
"github.com/labstack/echo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Setup
|
||||||
|
e := echo.New()
|
||||||
|
e.Get("/", func(c *echo.Context) error {
|
||||||
|
c.String(http.StatusOK, "Six sick bricks tick")
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
// Use github.com/facebookgo/grace/gracehttp
|
||||||
|
gracehttp.Serve(e.Server(":1323"))
|
||||||
|
}
|
21
examples/graceful/server.go
Normal file
21
examples/graceful/server.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/labstack/echo"
|
||||||
|
"github.com/tylerb/graceful"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Setup
|
||||||
|
e := echo.New()
|
||||||
|
e.Get("/", func(c *echo.Context) error {
|
||||||
|
c.String(http.StatusOK, "Sue sews rose on slow jor crows nose")
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
// Use github.com/tylerb/graceful
|
||||||
|
graceful.ListenAndServe(e.Server(":1323"), 5*time.Second)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user