mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
logger new api, updated recipes
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
9baa8bb8b3
commit
17c8b8f2ea
2
echo.go
2
echo.go
@ -31,7 +31,7 @@ Example:
|
||||
|
||||
// Start server
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
14
glide.lock
generated
14
glide.lock
generated
@ -1,5 +1,5 @@
|
||||
hash: b592629b56c43e0f6fcef629a3e46106b07431120d42ed45952d841655407e3e
|
||||
updated: 2016-10-20T16:35:55.384756891-07:00
|
||||
updated: 2016-10-23T13:10:42.580474947-07:00
|
||||
imports:
|
||||
- name: github.com/daaku/go.zipexe
|
||||
version: a5fe2436ffcb3236e175e5149162b41cd28bd27d
|
||||
@ -14,11 +14,11 @@ imports:
|
||||
subpackages:
|
||||
- proto
|
||||
- name: github.com/gorilla/websocket
|
||||
version: 460e0a996e9004dce40c3697e5ed4d7bc5a69b93
|
||||
version: 0b847f2facc24ec406130a05bb1bb72d41993b05
|
||||
- name: github.com/kardianos/osext
|
||||
version: c2c54e542fb797ad986b31721e1baedf214ca413
|
||||
- name: github.com/labstack/gommon
|
||||
version: f3b1a1b3bd4726161e1200863d278df7da5e66ff
|
||||
version: 2d272df536d051e737aea353b86c979d6e88bce0
|
||||
subpackages:
|
||||
- bytes
|
||||
- color
|
||||
@ -41,17 +41,17 @@ imports:
|
||||
subpackages:
|
||||
- acme
|
||||
- name: golang.org/x/crypto
|
||||
version: 3ded668c5379f6951fb0de06174442072e5447d3
|
||||
version: 3c0d69f1777220f1a1d2ec373cb94a282f03eb42
|
||||
subpackages:
|
||||
- ocsp
|
||||
- name: golang.org/x/net
|
||||
version: daba796358cd2742b75aae05761f1b898c9f6a5c
|
||||
version: c33d37840d93fc75251f49ab83c5fc8b2faea5e8
|
||||
subpackages:
|
||||
- context
|
||||
- publicsuffix
|
||||
- websocket
|
||||
- name: golang.org/x/sys
|
||||
version: 002cbb5f952456d0c50e0d2aff17ea5eca716979
|
||||
version: c200b10b5d5e122be351b67af224adc6128af5bf
|
||||
subpackages:
|
||||
- unix
|
||||
- name: golang.org/x/time
|
||||
@ -79,7 +79,7 @@ testImports:
|
||||
subpackages:
|
||||
- spew
|
||||
- name: github.com/pmezard/go-difflib
|
||||
version: 792786c7400a136282c1664665ae0a8db921c6c2
|
||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||
subpackages:
|
||||
- difflib
|
||||
- name: github.com/stretchr/testify
|
||||
|
@ -33,5 +33,8 @@ type (
|
||||
Fatal(...interface{})
|
||||
Fatalj(log.JSON)
|
||||
Fatalf(string, ...interface{})
|
||||
Panic(...interface{})
|
||||
Panicj(log.JSON)
|
||||
Panicf(string, ...interface{})
|
||||
}
|
||||
)
|
||||
|
@ -15,7 +15,7 @@ type (
|
||||
// Skipper defines a function to skip middleware.
|
||||
Skipper Skipper
|
||||
|
||||
// Prefix to strip from the request URL path.
|
||||
// Prefix to strip from the request URL path. Typically used with `Echo#Group`.
|
||||
// Optional. Default value "".
|
||||
Prefix string `json:"root"`
|
||||
|
||||
|
@ -35,6 +35,6 @@ func main() {
|
||||
e.GET("/api/users", getUsers)
|
||||
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ func main() {
|
||||
|
||||
// Start server
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ func main() {
|
||||
e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", assetHandler)))
|
||||
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -57,11 +57,11 @@ func main() {
|
||||
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.Static( "public"))
|
||||
e.Use(middleware.Static("public"))
|
||||
|
||||
e.POST("/upload", upload)
|
||||
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ func main() {
|
||||
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.Static( "public"))
|
||||
e.Use(middleware.Static("public"))
|
||||
|
||||
e.POST("/upload", upload)
|
||||
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ func createMux() *echo.Echo {
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Gzip())
|
||||
|
||||
e.Use(middleware.Static( "public"))
|
||||
e.Use(middleware.Static("public"))
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := e.Start(":8080"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ func main() {
|
||||
|
||||
// Start server
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,6 @@ func main() {
|
||||
e.GET("/request", request)
|
||||
e.GET("/stream", stream)
|
||||
if err := e.StartTLS(":1323", "cert.pem", "key.pem"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ func main() {
|
||||
e := echo.New()
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.Static( "public"))
|
||||
e.Use(middleware.Static("public"))
|
||||
|
||||
// JSONP
|
||||
e.GET("/jsonp", func(c echo.Context) error {
|
||||
@ -31,6 +31,6 @@ func main() {
|
||||
|
||||
// Start server
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,6 @@ func main() {
|
||||
r.GET("", restricted)
|
||||
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,6 @@ func main() {
|
||||
r.GET("", restricted)
|
||||
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,6 @@ func main() {
|
||||
|
||||
// Start server
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,6 @@ func main() {
|
||||
return nil
|
||||
})
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,6 @@ func main() {
|
||||
return
|
||||
})
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,9 @@ func main() {
|
||||
e := echo.New()
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.Static( "../public"))
|
||||
e.Use(middleware.Static("../public"))
|
||||
e.GET("/ws", hello)
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ func main() {
|
||||
e := echo.New()
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.Static( "../public"))
|
||||
e.Use(middleware.Static("../public"))
|
||||
e.GET("/ws", hello)
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
panic(err)
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -39,25 +39,29 @@ This serves static files from `static` directory and enables directory browsing.
|
||||
|
||||
```go
|
||||
StaticConfig struct {
|
||||
// Skipper defines a function to skip middleware.
|
||||
Skipper Skipper
|
||||
// Skipper defines a function to skip middleware.
|
||||
Skipper Skipper
|
||||
|
||||
// Root directory from where the static content is served.
|
||||
// Required.
|
||||
Root string `json:"root"`
|
||||
// Prefix to strip from the request URL path. Typically used with `Echo#Group`.
|
||||
// Optional. Default value "".
|
||||
Prefix string `json:"root"`
|
||||
|
||||
// Index file for serving a directory.
|
||||
// Optional. Default value "index.html".
|
||||
Index string `json:"index"`
|
||||
// Root directory from where the static content is served.
|
||||
// Required.
|
||||
Root string `json:"root"`
|
||||
|
||||
// Enable HTML5 mode by forwarding all not-found requests to root so that
|
||||
// SPA (single-page application) can handle the routing.
|
||||
// Optional. Default value false.
|
||||
HTML5 bool `json:"html5"`
|
||||
// Index file for serving a directory.
|
||||
// Optional. Default value "index.html".
|
||||
Index string `json:"index"`
|
||||
|
||||
// Enable directory browsing.
|
||||
// Optional. Default value false.
|
||||
Browse bool `json:"browse"`
|
||||
// Enable HTML5 mode by forwarding all not-found requests to root so that
|
||||
// SPA (single-page application) can handle the routing.
|
||||
// Optional. Default value false.
|
||||
HTML5 bool `json:"html5"`
|
||||
|
||||
// Enable directory browsing.
|
||||
// Optional. Default value false.
|
||||
Browse bool `json:"browse"`
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user