1
0
mirror of https://github.com/kataras/iris.git synced 2026-03-03 15:06:03 +00:00

request logger middleware: add graphical information about executed route's handlers

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-19 01:24:36 +03:00
parent 4228dd8ea4
commit bdb94bbae2
6 changed files with 74 additions and 31 deletions

View File

@@ -231,22 +231,22 @@ Take for example that you want to fire different HTTP status codes depending on
```go
type response struct {
ID uint64 `json:"id,omitempty"`
Message string `json:"message"`
Code int `json:"code"`
Timestamp int64 `json:"timestamp,omitempty"`
ID uint64 `json:"id,omitempty"`
Message string `json:"message"`
Code int `json:"code"`
Timestamp int64 `json:"timestamp,omitempty"`
}
func (r *response) Preflight(ctx iris.Context) error {
if r.ID > 0 {
r.Timestamp = time.Now().Unix()
}
if r.ID > 0 {
r.Timestamp = time.Now().Unix()
}
if r.Code > 0 {
ctx.StatusCode(r.Code)
}
return nil
return nil
}
```
@@ -362,7 +362,7 @@ Response:
Other Improvements:
- New `TraceRoute bool` on [request logger](https://github.com/kataras/iris/tree/master/middleware/logger) middleware. Displays information about the executed route, screenshot:
- New `TraceRoute bool` on [request logger](https://github.com/kataras/iris/tree/master/middleware/logger) middleware. Displays information about the executed route. Also marks the handlers executed. Screenshot:
![logger middleware: TraceRoute screenshot](https://iris-go.com/images/github/logger-trace-route.png)