diff --git a/glide.lock b/glide.lock index bc8c1b92..c51f7aac 100644 --- a/glide.lock +++ b/glide.lock @@ -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 diff --git a/glide.yaml b/glide.yaml index 0c71b3c6..9ac9d1c8 100644 --- a/glide.yaml +++ b/glide.yaml @@ -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: diff --git a/middleware/basic_auth.go b/middleware/basic_auth.go index 5dd377f5..e98a87e3 100644 --- a/middleware/basic_auth.go +++ b/middleware/basic_auth.go @@ -28,7 +28,7 @@ const ( var ( // DefaultBasicAuthConfig is the default BasicAuth middleware config. DefaultBasicAuthConfig = BasicAuthConfig{ - Skipper: defaultSkipper, + Skipper: DefaultSkipper, } ) diff --git a/middleware/body_limit.go b/middleware/body_limit.go index 84654bbc..a2ff8d62 100644 --- a/middleware/body_limit.go +++ b/middleware/body_limit.go @@ -32,7 +32,7 @@ type ( var ( // DefaultBodyLimitConfig is the default Gzip middleware config. DefaultBodyLimitConfig = BodyLimitConfig{ - Skipper: defaultSkipper, + Skipper: DefaultSkipper, } ) diff --git a/middleware/compress.go b/middleware/compress.go index a69d2b76..3d4a7622 100644 --- a/middleware/compress.go +++ b/middleware/compress.go @@ -36,7 +36,7 @@ const ( var ( // DefaultGzipConfig is the default Gzip middleware config. DefaultGzipConfig = GzipConfig{ - Skipper: defaultSkipper, + Skipper: DefaultSkipper, Level: -1, } ) diff --git a/middleware/cors.go b/middleware/cors.go index 5e4ea675..c35fc36c 100644 --- a/middleware/cors.go +++ b/middleware/cors.go @@ -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}, } diff --git a/middleware/csrf.go b/middleware/csrf.go index 607ccd7b..5bbeecb4 100644 --- a/middleware/csrf.go +++ b/middleware/csrf.go @@ -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", diff --git a/middleware/jwt.go b/middleware/jwt.go index fd12fd94..b2658739 100644 --- a/middleware/jwt.go +++ b/middleware/jwt.go @@ -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, diff --git a/middleware/key_auth.go b/middleware/key_auth.go index 472fa70f..4d4cb940 100644 --- a/middleware/key_auth.go +++ b/middleware/key_auth.go @@ -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", } diff --git a/middleware/logger.go b/middleware/logger.go index 70278371..e26b5496 100644 --- a/middleware/logger.go +++ b/middleware/logger.go @@ -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": diff --git a/middleware/method_override.go b/middleware/method_override.go index dcc94b0f..955fd11e 100644 --- a/middleware/method_override.go +++ b/middleware/method_override.go @@ -20,7 +20,7 @@ type ( var ( // DefaultMethodOverrideConfig is the default MethodOverride middleware config. DefaultMethodOverrideConfig = MethodOverrideConfig{ - Skipper: defaultSkipper, + Skipper: DefaultSkipper, Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride), } ) diff --git a/middleware/middleware.go b/middleware/middleware.go index bf3e07c4..7edccc1d 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -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 } diff --git a/middleware/recover.go b/middleware/recover.go index 1bf169ef..96fa62c9 100644 --- a/middleware/recover.go +++ b/middleware/recover.go @@ -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, diff --git a/middleware/redirect.go b/middleware/redirect.go index 8e926c75..b87dab09 100644 --- a/middleware/redirect.go +++ b/middleware/redirect.go @@ -25,7 +25,7 @@ const ( var ( // DefaultRedirectConfig is the default Redirect middleware config. DefaultRedirectConfig = RedirectConfig{ - Skipper: defaultSkipper, + Skipper: DefaultSkipper, Code: http.StatusMovedPermanently, } ) diff --git a/middleware/secure.go b/middleware/secure.go index 725f8f61..0125e74a 100644 --- a/middleware/secure.go +++ b/middleware/secure.go @@ -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", diff --git a/middleware/slash.go b/middleware/slash.go index 540bae3f..1114d722 100644 --- a/middleware/slash.go +++ b/middleware/slash.go @@ -19,7 +19,7 @@ type ( var ( // DefaultTrailingSlashConfig is the default TrailingSlash middleware config. DefaultTrailingSlashConfig = TrailingSlashConfig{ - Skipper: defaultSkipper, + Skipper: DefaultSkipper, } ) diff --git a/website/content/guide/faq.md b/website/content/guide/faq.md index 23e38b40..c4bee720 100644 --- a/website/content/guide/faq.md +++ b/website/content/guide/faq.md @@ -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 +``` + diff --git a/website/content/guide/installation.md b/website/content/guide/installation.md index 3495ac16..b05a6dda 100644 --- a/website/content/guide/installation.md +++ b/website/content/guide/installation.md @@ -16,7 +16,7 @@ description = "Installing Echo" ```sh $ cd -$ go get -u github.com/labstack/echo +$ go get -u github.com/labstack/echo/... ``` ## Using [glide](http://glide.sh) diff --git a/website/content/middleware/logger.md b/website/content/middleware/logger.md index 564d15b5..0ffa0c7f 100644 --- a/website/content/middleware/logger.md +++ b/website/content/middleware/logger.md @@ -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)