summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/middleware/request_id.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-01-31 17:06:36 +0100
committerWim <wim@42.be>2019-01-31 17:06:36 +0100
commitc81c0dd22a7779148c4890cfd4bbf490054f06f1 (patch)
tree06ce6fcdc8f3a2278a2f3050ba42088dd2e64485 /vendor/github.com/labstack/echo/middleware/request_id.go
parentf8a1ab4622a5b833282e9ee42f382451d17c1a06 (diff)
downloadmatterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.gz
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.bz2
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.zip
Update vendor, move to labstack/echo/v4 Fixes #698
Diffstat (limited to 'vendor/github.com/labstack/echo/middleware/request_id.go')
-rw-r--r--vendor/github.com/labstack/echo/middleware/request_id.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/vendor/github.com/labstack/echo/middleware/request_id.go b/vendor/github.com/labstack/echo/middleware/request_id.go
deleted file mode 100644
index f376c296..00000000
--- a/vendor/github.com/labstack/echo/middleware/request_id.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package middleware
-
-import (
- "github.com/labstack/echo"
- "github.com/labstack/gommon/random"
-)
-
-type (
- // RequestIDConfig defines the config for RequestID middleware.
- RequestIDConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
-
- // Generator defines a function to generate an ID.
- // Optional. Default value random.String(32).
- Generator func() string
- }
-)
-
-var (
- // DefaultRequestIDConfig is the default RequestID middleware config.
- DefaultRequestIDConfig = RequestIDConfig{
- Skipper: DefaultSkipper,
- Generator: generator,
- }
-)
-
-// RequestID returns a X-Request-ID middleware.
-func RequestID() echo.MiddlewareFunc {
- return RequestIDWithConfig(DefaultRequestIDConfig)
-}
-
-// RequestIDWithConfig returns a X-Request-ID middleware with config.
-func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc {
- // Defaults
- if config.Skipper == nil {
- config.Skipper = DefaultRequestIDConfig.Skipper
- }
- if config.Generator == nil {
- config.Generator = generator
- }
-
- return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
- if config.Skipper(c) {
- return next(c)
- }
-
- req := c.Request()
- res := c.Response()
- rid := req.Header.Get(echo.HeaderXRequestID)
- if rid == "" {
- rid = config.Generator()
- }
- res.Header().Set(echo.HeaderXRequestID, rid)
-
- return next(c)
- }
- }
-}
-
-func generator() string {
- return random.String(32)
-}