mirror of
https://github.com/labstack/echo.git
synced 2024-11-24 08:22:21 +02:00
Updated docs, exposed middleware.DefaultSkipper
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
aa483fd34f
commit
52fa135fd5
10
glide.lock
generated
10
glide.lock
generated
@ -1,5 +1,5 @@
|
||||
hash: 4a4f41416395516f7eefabd29ee5c7b065a411dec7446f6d6853d4cc28c4c644
|
||||
updated: 2017-01-21T10:20:13.866484425-08:00
|
||||
hash: 3de2a96bbdc145cce325de2a482111b0524cc330f60a4fbc781a08ed3b879e58
|
||||
updated: 2017-01-28T10:22:00.230111692-08:00
|
||||
imports:
|
||||
- name: github.com/daaku/go.zipexe
|
||||
version: a5fe2436ffcb3236e175e5149162b41cd28bd27d
|
||||
@ -17,7 +17,7 @@ imports:
|
||||
- name: github.com/facebookgo/stats
|
||||
version: 1b76add642e42c6ffba7211ad7b3939ce654526e
|
||||
- name: github.com/GeertJohan/go.rice
|
||||
version: 9fdfd46f9806a9228aae341d65ab75c5235c383c
|
||||
version: 4bbccbfa39e784796e483270451217d3369ecfbe
|
||||
subpackages:
|
||||
- embedded
|
||||
- name: github.com/golang/protobuf
|
||||
@ -25,7 +25,7 @@ imports:
|
||||
subpackages:
|
||||
- proto
|
||||
- name: github.com/gorilla/websocket
|
||||
version: 2257eda00b2084c1351cd672aa5476daa9f5e463
|
||||
version: c36f2fe5c330f0ac404b616b96c438b8616b1aaf
|
||||
- name: github.com/kardianos/osext
|
||||
version: c2c54e542fb797ad986b31721e1baedf214ca413
|
||||
- name: github.com/labstack/gommon
|
||||
@ -46,7 +46,7 @@ imports:
|
||||
- name: github.com/valyala/fasttemplate
|
||||
version: d090d65668a286d9a180d43a19dfdc5dcad8fe88
|
||||
- name: golang.org/x/crypto
|
||||
version: b8a2a83acfe6e6770b75de42d5ff4c67596675c0
|
||||
version: 9477e0b78b9ac3d0b03822fd95422e2fe07627cd
|
||||
subpackages:
|
||||
- acme
|
||||
- acme/autocert
|
||||
|
@ -2,6 +2,9 @@ package: github.com/labstack/echo
|
||||
import:
|
||||
- package: github.com/GeertJohan/go.rice
|
||||
- package: github.com/dgrijalva/jwt-go
|
||||
- package: github.com/facebookgo/grace
|
||||
subpackages:
|
||||
- gracehttp
|
||||
- package: github.com/gorilla/websocket
|
||||
- package: github.com/labstack/gommon
|
||||
subpackages:
|
||||
@ -9,7 +12,7 @@ import:
|
||||
- color
|
||||
- log
|
||||
- random
|
||||
- package: github.com/mattn/go-isatty
|
||||
- package: github.com/tylerb/graceful
|
||||
- package: github.com/valyala/fasttemplate
|
||||
- package: golang.org/x/crypto
|
||||
subpackages:
|
||||
@ -21,7 +24,6 @@ import:
|
||||
- package: gopkg.in/mgo.v2
|
||||
subpackages:
|
||||
- bson
|
||||
- package: github.com/facebookgo/grace
|
||||
testImport:
|
||||
- package: github.com/stretchr/testify
|
||||
subpackages:
|
||||
|
@ -28,7 +28,7 @@ const (
|
||||
var (
|
||||
// DefaultBasicAuthConfig is the default BasicAuth middleware config.
|
||||
DefaultBasicAuthConfig = BasicAuthConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -32,7 +32,7 @@ type (
|
||||
var (
|
||||
// DefaultBodyLimitConfig is the default Gzip middleware config.
|
||||
DefaultBodyLimitConfig = BodyLimitConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -36,7 +36,7 @@ const (
|
||||
var (
|
||||
// DefaultGzipConfig is the default Gzip middleware config.
|
||||
DefaultGzipConfig = GzipConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
Level: -1,
|
||||
}
|
||||
)
|
||||
|
@ -50,7 +50,7 @@ type (
|
||||
var (
|
||||
// DefaultCORSConfig is the default CORS middleware config.
|
||||
DefaultCORSConfig = CORSConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
AllowOrigins: []string{"*"},
|
||||
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ type (
|
||||
var (
|
||||
// DefaultCSRFConfig is the default CSRF middleware config.
|
||||
DefaultCSRFConfig = CSRFConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
TokenLength: 32,
|
||||
TokenLookup: "header:" + echo.HeaderXCSRFToken,
|
||||
ContextKey: "csrf",
|
||||
|
@ -60,7 +60,7 @@ const (
|
||||
var (
|
||||
// DefaultJWTConfig is the default JWT auth middleware config.
|
||||
DefaultJWTConfig = JWTConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
SigningMethod: AlgorithmHS256,
|
||||
ContextKey: "user",
|
||||
TokenLookup: "header:" + echo.HeaderAuthorization,
|
||||
|
@ -40,7 +40,7 @@ type (
|
||||
var (
|
||||
// DefaultKeyAuthConfig is the default KeyAuth middleware config.
|
||||
DefaultKeyAuthConfig = KeyAuthConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
KeyLookup: "header:" + echo.HeaderAuthorization,
|
||||
AuthScheme: "Bearer",
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ type (
|
||||
// - referer
|
||||
// - user_agent
|
||||
// - status
|
||||
// - latency (In microseconds)
|
||||
// - latency (In nanoseconds)
|
||||
// - latency_human (Human readable)
|
||||
// - bytes_in (Bytes received)
|
||||
// - bytes_out (Bytes sent)
|
||||
@ -61,7 +61,7 @@ type (
|
||||
var (
|
||||
// DefaultLoggerConfig is the default Logger middleware config.
|
||||
DefaultLoggerConfig = LoggerConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
Format: `{"time":"${time_rfc3339_nano}","remote_ip":"${remote_ip}","host":"${host}",` +
|
||||
`"method":"${method}","uri":"${uri}","status":${status}, "latency":${latency},` +
|
||||
`"latency_human":"${latency_human}","bytes_in":${bytes_in},` +
|
||||
@ -157,8 +157,8 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
|
||||
}
|
||||
return buf.WriteString(s)
|
||||
case "latency":
|
||||
l := stop.Sub(start).Nanoseconds() / int64(time.Microsecond)
|
||||
return buf.WriteString(strconv.FormatInt(l, 10))
|
||||
l := stop.Sub(start)
|
||||
return buf.WriteString(strconv.FormatInt(int64(l), 10))
|
||||
case "latency_human":
|
||||
return buf.WriteString(stop.Sub(start).String())
|
||||
case "bytes_in":
|
||||
|
@ -20,7 +20,7 @@ type (
|
||||
var (
|
||||
// DefaultMethodOverrideConfig is the default MethodOverride middleware config.
|
||||
DefaultMethodOverrideConfig = MethodOverrideConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride),
|
||||
}
|
||||
)
|
||||
|
@ -8,7 +8,7 @@ type (
|
||||
Skipper func(c echo.Context) bool
|
||||
)
|
||||
|
||||
// defaultSkipper returns false which processes the middleware.
|
||||
func defaultSkipper(c echo.Context) bool {
|
||||
// DefaultSkipper returns false which processes the middleware.
|
||||
func DefaultSkipper(c echo.Context) bool {
|
||||
return false
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ type (
|
||||
var (
|
||||
// DefaultRecoverConfig is the default Recover middleware config.
|
||||
DefaultRecoverConfig = RecoverConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
StackSize: 4 << 10, // 4 KB
|
||||
DisableStackAll: false,
|
||||
DisablePrintStack: false,
|
||||
|
@ -25,7 +25,7 @@ const (
|
||||
var (
|
||||
// DefaultRedirectConfig is the default Redirect middleware config.
|
||||
DefaultRedirectConfig = RedirectConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
Code: http.StatusMovedPermanently,
|
||||
}
|
||||
)
|
||||
|
@ -59,7 +59,7 @@ type (
|
||||
var (
|
||||
// DefaultSecureConfig is the default Secure middleware config.
|
||||
DefaultSecureConfig = SecureConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
XSSProtection: "1; mode=block",
|
||||
ContentTypeNosniff: "nosniff",
|
||||
XFrameOptions: "SAMEORIGIN",
|
||||
|
@ -19,7 +19,7 @@ type (
|
||||
var (
|
||||
// DefaultTrailingSlashConfig is the default TrailingSlash middleware config.
|
||||
DefaultTrailingSlashConfig = TrailingSlashConfig{
|
||||
Skipper: defaultSkipper,
|
||||
Skipper: DefaultSkipper,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -57,3 +57,24 @@ Q: How to run Echo on a random port?
|
||||
```go
|
||||
e.Start(":0")
|
||||
```
|
||||
|
||||
Q: How to run Echo on a unix domain socket?
|
||||
|
||||
```go
|
||||
e := echo.New()
|
||||
e.GET("/", func(c echo.Context) error {
|
||||
return c.String(http.StatusOK, "OK")
|
||||
})
|
||||
os.Remove("/tmp/echo.sock")
|
||||
l, err := net.Listen("unix", "/tmp/echo.sock")
|
||||
if err != nil {
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
e.Listener = l
|
||||
e.Logger.Fatal(e.Start(""))
|
||||
```
|
||||
|
||||
```sh
|
||||
curl --unix-socket /tmp/echo.sock http://localhost
|
||||
```
|
||||
|
||||
|
@ -16,7 +16,7 @@ description = "Installing Echo"
|
||||
|
||||
```sh
|
||||
$ cd <project in $GOPATH>
|
||||
$ go get -u github.com/labstack/echo
|
||||
$ go get -u github.com/labstack/echo/...
|
||||
```
|
||||
|
||||
## Using [glide](http://glide.sh)
|
||||
|
@ -60,7 +60,7 @@ LoggerConfig struct {
|
||||
// - referer
|
||||
// - user_agent
|
||||
// - status
|
||||
// - latency (In microseconds)
|
||||
// - latency (In nanoseconds)
|
||||
// - latency_human (Human readable)
|
||||
// - bytes_in (Bytes received)
|
||||
// - bytes_out (Bytes sent)
|
||||
|
Loading…
Reference in New Issue
Block a user