1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-28 08:38:39 +02:00

Updated docs, exposed middleware.DefaultSkipper

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2017-01-28 11:43:56 -08:00
parent aa483fd34f
commit 52fa135fd5
19 changed files with 50 additions and 27 deletions

10
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: 4a4f41416395516f7eefabd29ee5c7b065a411dec7446f6d6853d4cc28c4c644 hash: 3de2a96bbdc145cce325de2a482111b0524cc330f60a4fbc781a08ed3b879e58
updated: 2017-01-21T10:20:13.866484425-08:00 updated: 2017-01-28T10:22:00.230111692-08:00
imports: imports:
- name: github.com/daaku/go.zipexe - name: github.com/daaku/go.zipexe
version: a5fe2436ffcb3236e175e5149162b41cd28bd27d version: a5fe2436ffcb3236e175e5149162b41cd28bd27d
@ -17,7 +17,7 @@ imports:
- name: github.com/facebookgo/stats - name: github.com/facebookgo/stats
version: 1b76add642e42c6ffba7211ad7b3939ce654526e version: 1b76add642e42c6ffba7211ad7b3939ce654526e
- name: github.com/GeertJohan/go.rice - name: github.com/GeertJohan/go.rice
version: 9fdfd46f9806a9228aae341d65ab75c5235c383c version: 4bbccbfa39e784796e483270451217d3369ecfbe
subpackages: subpackages:
- embedded - embedded
- name: github.com/golang/protobuf - name: github.com/golang/protobuf
@ -25,7 +25,7 @@ imports:
subpackages: subpackages:
- proto - proto
- name: github.com/gorilla/websocket - name: github.com/gorilla/websocket
version: 2257eda00b2084c1351cd672aa5476daa9f5e463 version: c36f2fe5c330f0ac404b616b96c438b8616b1aaf
- name: github.com/kardianos/osext - name: github.com/kardianos/osext
version: c2c54e542fb797ad986b31721e1baedf214ca413 version: c2c54e542fb797ad986b31721e1baedf214ca413
- name: github.com/labstack/gommon - name: github.com/labstack/gommon
@ -46,7 +46,7 @@ imports:
- name: github.com/valyala/fasttemplate - name: github.com/valyala/fasttemplate
version: d090d65668a286d9a180d43a19dfdc5dcad8fe88 version: d090d65668a286d9a180d43a19dfdc5dcad8fe88
- name: golang.org/x/crypto - name: golang.org/x/crypto
version: b8a2a83acfe6e6770b75de42d5ff4c67596675c0 version: 9477e0b78b9ac3d0b03822fd95422e2fe07627cd
subpackages: subpackages:
- acme - acme
- acme/autocert - acme/autocert

View File

@ -2,6 +2,9 @@ package: github.com/labstack/echo
import: import:
- package: github.com/GeertJohan/go.rice - package: github.com/GeertJohan/go.rice
- package: github.com/dgrijalva/jwt-go - package: github.com/dgrijalva/jwt-go
- package: github.com/facebookgo/grace
subpackages:
- gracehttp
- package: github.com/gorilla/websocket - package: github.com/gorilla/websocket
- package: github.com/labstack/gommon - package: github.com/labstack/gommon
subpackages: subpackages:
@ -9,7 +12,7 @@ import:
- color - color
- log - log
- random - random
- package: github.com/mattn/go-isatty - package: github.com/tylerb/graceful
- package: github.com/valyala/fasttemplate - package: github.com/valyala/fasttemplate
- package: golang.org/x/crypto - package: golang.org/x/crypto
subpackages: subpackages:
@ -21,7 +24,6 @@ import:
- package: gopkg.in/mgo.v2 - package: gopkg.in/mgo.v2
subpackages: subpackages:
- bson - bson
- package: github.com/facebookgo/grace
testImport: testImport:
- package: github.com/stretchr/testify - package: github.com/stretchr/testify
subpackages: subpackages:

View File

@ -28,7 +28,7 @@ const (
var ( var (
// DefaultBasicAuthConfig is the default BasicAuth middleware config. // DefaultBasicAuthConfig is the default BasicAuth middleware config.
DefaultBasicAuthConfig = BasicAuthConfig{ DefaultBasicAuthConfig = BasicAuthConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
} }
) )

View File

@ -32,7 +32,7 @@ type (
var ( var (
// DefaultBodyLimitConfig is the default Gzip middleware config. // DefaultBodyLimitConfig is the default Gzip middleware config.
DefaultBodyLimitConfig = BodyLimitConfig{ DefaultBodyLimitConfig = BodyLimitConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
} }
) )

View File

@ -36,7 +36,7 @@ const (
var ( var (
// DefaultGzipConfig is the default Gzip middleware config. // DefaultGzipConfig is the default Gzip middleware config.
DefaultGzipConfig = GzipConfig{ DefaultGzipConfig = GzipConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
Level: -1, Level: -1,
} }
) )

View File

@ -50,7 +50,7 @@ type (
var ( var (
// DefaultCORSConfig is the default CORS middleware config. // DefaultCORSConfig is the default CORS middleware config.
DefaultCORSConfig = CORSConfig{ DefaultCORSConfig = CORSConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
AllowOrigins: []string{"*"}, AllowOrigins: []string{"*"},
AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE}, AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
} }

View File

@ -67,7 +67,7 @@ type (
var ( var (
// DefaultCSRFConfig is the default CSRF middleware config. // DefaultCSRFConfig is the default CSRF middleware config.
DefaultCSRFConfig = CSRFConfig{ DefaultCSRFConfig = CSRFConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
TokenLength: 32, TokenLength: 32,
TokenLookup: "header:" + echo.HeaderXCSRFToken, TokenLookup: "header:" + echo.HeaderXCSRFToken,
ContextKey: "csrf", ContextKey: "csrf",

View File

@ -60,7 +60,7 @@ const (
var ( var (
// DefaultJWTConfig is the default JWT auth middleware config. // DefaultJWTConfig is the default JWT auth middleware config.
DefaultJWTConfig = JWTConfig{ DefaultJWTConfig = JWTConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
SigningMethod: AlgorithmHS256, SigningMethod: AlgorithmHS256,
ContextKey: "user", ContextKey: "user",
TokenLookup: "header:" + echo.HeaderAuthorization, TokenLookup: "header:" + echo.HeaderAuthorization,

View File

@ -40,7 +40,7 @@ type (
var ( var (
// DefaultKeyAuthConfig is the default KeyAuth middleware config. // DefaultKeyAuthConfig is the default KeyAuth middleware config.
DefaultKeyAuthConfig = KeyAuthConfig{ DefaultKeyAuthConfig = KeyAuthConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
KeyLookup: "header:" + echo.HeaderAuthorization, KeyLookup: "header:" + echo.HeaderAuthorization,
AuthScheme: "Bearer", AuthScheme: "Bearer",
} }

View File

@ -35,7 +35,7 @@ type (
// - referer // - referer
// - user_agent // - user_agent
// - status // - status
// - latency (In microseconds) // - latency (In nanoseconds)
// - latency_human (Human readable) // - latency_human (Human readable)
// - bytes_in (Bytes received) // - bytes_in (Bytes received)
// - bytes_out (Bytes sent) // - bytes_out (Bytes sent)
@ -61,7 +61,7 @@ type (
var ( var (
// DefaultLoggerConfig is the default Logger middleware config. // DefaultLoggerConfig is the default Logger middleware config.
DefaultLoggerConfig = LoggerConfig{ DefaultLoggerConfig = LoggerConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
Format: `{"time":"${time_rfc3339_nano}","remote_ip":"${remote_ip}","host":"${host}",` + Format: `{"time":"${time_rfc3339_nano}","remote_ip":"${remote_ip}","host":"${host}",` +
`"method":"${method}","uri":"${uri}","status":${status}, "latency":${latency},` + `"method":"${method}","uri":"${uri}","status":${status}, "latency":${latency},` +
`"latency_human":"${latency_human}","bytes_in":${bytes_in},` + `"latency_human":"${latency_human}","bytes_in":${bytes_in},` +
@ -157,8 +157,8 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
} }
return buf.WriteString(s) return buf.WriteString(s)
case "latency": case "latency":
l := stop.Sub(start).Nanoseconds() / int64(time.Microsecond) l := stop.Sub(start)
return buf.WriteString(strconv.FormatInt(l, 10)) return buf.WriteString(strconv.FormatInt(int64(l), 10))
case "latency_human": case "latency_human":
return buf.WriteString(stop.Sub(start).String()) return buf.WriteString(stop.Sub(start).String())
case "bytes_in": case "bytes_in":

View File

@ -20,7 +20,7 @@ type (
var ( var (
// DefaultMethodOverrideConfig is the default MethodOverride middleware config. // DefaultMethodOverrideConfig is the default MethodOverride middleware config.
DefaultMethodOverrideConfig = MethodOverrideConfig{ DefaultMethodOverrideConfig = MethodOverrideConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride), Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride),
} }
) )

View File

@ -8,7 +8,7 @@ type (
Skipper func(c echo.Context) bool Skipper func(c echo.Context) bool
) )
// defaultSkipper returns false which processes the middleware. // DefaultSkipper returns false which processes the middleware.
func defaultSkipper(c echo.Context) bool { func DefaultSkipper(c echo.Context) bool {
return false return false
} }

View File

@ -32,7 +32,7 @@ type (
var ( var (
// DefaultRecoverConfig is the default Recover middleware config. // DefaultRecoverConfig is the default Recover middleware config.
DefaultRecoverConfig = RecoverConfig{ DefaultRecoverConfig = RecoverConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
StackSize: 4 << 10, // 4 KB StackSize: 4 << 10, // 4 KB
DisableStackAll: false, DisableStackAll: false,
DisablePrintStack: false, DisablePrintStack: false,

View File

@ -25,7 +25,7 @@ const (
var ( var (
// DefaultRedirectConfig is the default Redirect middleware config. // DefaultRedirectConfig is the default Redirect middleware config.
DefaultRedirectConfig = RedirectConfig{ DefaultRedirectConfig = RedirectConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
Code: http.StatusMovedPermanently, Code: http.StatusMovedPermanently,
} }
) )

View File

@ -59,7 +59,7 @@ type (
var ( var (
// DefaultSecureConfig is the default Secure middleware config. // DefaultSecureConfig is the default Secure middleware config.
DefaultSecureConfig = SecureConfig{ DefaultSecureConfig = SecureConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
XSSProtection: "1; mode=block", XSSProtection: "1; mode=block",
ContentTypeNosniff: "nosniff", ContentTypeNosniff: "nosniff",
XFrameOptions: "SAMEORIGIN", XFrameOptions: "SAMEORIGIN",

View File

@ -19,7 +19,7 @@ type (
var ( var (
// DefaultTrailingSlashConfig is the default TrailingSlash middleware config. // DefaultTrailingSlashConfig is the default TrailingSlash middleware config.
DefaultTrailingSlashConfig = TrailingSlashConfig{ DefaultTrailingSlashConfig = TrailingSlashConfig{
Skipper: defaultSkipper, Skipper: DefaultSkipper,
} }
) )

View File

@ -57,3 +57,24 @@ Q: How to run Echo on a random port?
```go ```go
e.Start(":0") 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
```

View File

@ -16,7 +16,7 @@ description = "Installing Echo"
```sh ```sh
$ cd <project in $GOPATH> $ cd <project in $GOPATH>
$ go get -u github.com/labstack/echo $ go get -u github.com/labstack/echo/...
``` ```
## Using [glide](http://glide.sh) ## Using [glide](http://glide.sh)

View File

@ -60,7 +60,7 @@ LoggerConfig struct {
// - referer // - referer
// - user_agent // - user_agent
// - status // - status
// - latency (In microseconds) // - latency (In nanoseconds)
// - latency_human (Human readable) // - latency_human (Human readable)
// - bytes_in (Bytes received) // - bytes_in (Bytes received)
// - bytes_out (Bytes sent) // - bytes_out (Bytes sent)