How can I convert an HttpResponse body to a struct? #1365
Unanswered
GSGerritsen
asked this question in
Q&A
Replies: 1 comment
-
I guess I'd suggest theres a different way to structure this so you don't have to call handlers from other handlers. Are you still having trouble with this @GSGerritsen? We can close this issue if you've solved your problem and would be interesting to know how you did it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a handler for my server that returns
Result<HttpResponse, ActixError>
, and I am calling that handler from a different handler.Which looks like:
let response = handler(request).await?;
I would like to convert the body of
response
into a struct, but I'm not seeing how to get a byte slice of the body of that response.I'd like to do something like this:
let some_struct = serde_json::from_slice::<SomeStruct>(handler(request).await?.body);
But I'm stuck on getting the body from the
HttpResponse
into a slice of u8.Can anyone offer guidance? Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions