Skip to content

Commit

Permalink
Update request-id.md
Browse files Browse the repository at this point in the history
update `middleware.RequestIDConfig` and add and example.
  • Loading branch information
mohammadhz98 authored and aldas committed Aug 31, 2023
1 parent 2cff881 commit 66cf0c9
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions website/docs/middleware/request-id.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ e.Use(middleware.RequestID())
*Example*

```go
e := echo.New()
e := echo.New()

e.Use(middleware.RequestID())
e.Use(middleware.RequestID())

e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, c.Response().Header().Get(echo.HeaderXRequestID))
})
e.Logger.Fatal(e.Start(":1323"))
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, c.Response().Header().Get(echo.HeaderXRequestID))
})
e.Logger.Fatal(e.Start(":1323"))
```

## Custom Configuration
Expand All @@ -41,18 +41,18 @@ e.Use(middleware.RequestIDWithConfig(middleware.RequestIDConfig{

```go
RequestIDConfig struct {
// Skipper defines a function to skip middleware.
Skipper Skipper
// 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
// Generator defines a function to generate an ID.
// Optional. Default value random.String(32).
Generator func() string

// RequestIDHandler defines a function which is executed for a request id.
RequestIDHandler func(echo.Context, string)
// RequestIDHandler defines a function which is executed for a request id.
RequestIDHandler func(echo.Context, string)

// TargetHeader defines what header to look for to populate the id
TargetHeader string
// TargetHeader defines what header to look for to populate the id
TargetHeader string
}
```

Expand Down

0 comments on commit 66cf0c9

Please sign in to comment.