Skip to content

Commit

Permalink
chore: [torrust#468] add new features to propagate ID in requests
Browse files Browse the repository at this point in the history
Add new features to `tower-http` crate to propagate the request ID to
the response. If the request does not have an ID it sets a newly
generated UUID.

```
$ curl -i localhost:3001/v1/about/license
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
content-length: 1262
x-request-id: cea0efcd-84e0-4f59-96b3-625ca4154396
date: Mon, 12 Feb 2024 16:58:05 GMT
```

```
$ curl -i -H "x-request-id: a5030c7a-5302-49d4-8e66-f0f0ab0e3ce3" localhost:3001/v1/about/license
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
content-length: 1262
x-request-id: a5030c7a-5302-49d4-8e66-f0f0ab0e3ce3
date: Mon, 12 Feb 2024 16:59:31 GMT
```

This commit onlu adds the needed features.
  • Loading branch information
josecelano committed Feb 12, 2024
1 parent e5ebcc0 commit 3ec28ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ thiserror = "1"
tokio = { version = "1", features = ["fs", "io-util", "macros", "net", "rt-multi-thread", "signal", "sync", "time"] }
toml = "0"
torrust-index-located-error = { version = "3.0.0-alpha.3-develop", path = "packages/located-error" }
tower-http = { version = "0", features = ["compression-full", "cors", "trace"] }
tower-http = { version = "0", features = ["compression-full", "cors", "trace", "propagate-header", "request-id"] }
trace = "0.1.7"
tracing = "0.1.40"
urlencoding = "2"
Expand Down

0 comments on commit 3ec28ba

Please sign in to comment.