-
Hello. I have a function which depending on some conditions, will return either a StatusCode with an empty body or a Redirect. I don't know what "type" should the function return. Edit: Similarly, in some other function, I have to return either a 400 with empty body or a 200 with json body. I am pretty new to Rust. Perhaps Rust has some "type" which is either "A type" or "B type"? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The function should return |
Beta Was this translation helpful? Give feedback.
The function should return
Response
. See an example here of how to convert both types of responses to a common type: https://docs.rs/axum/0.6.18/axum/response/index.html#returning-different-response-types