Skip to content

How to print the request body ? #1905

Discussion options

You must be logged in to vote

The second parameter to an on_request fairing (currently _ in your posted example) is an &mut Data, which can be used to peek at the beginning of the request data.

If you do need to read the entire data, you should use a data guard on the appropriate route instead - but see also #775 regarding some of the limitations. In particular, it's not easy out-of-the-box to both print the body data and do something else with it, such as parsing JSON input.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by paulzhang5511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants