Skip to content

How to use Response<BoxBody> with and without json payload in actix_http v3? #2676

Answered by robjtede
pmalek-sumo asked this question in Q&A
Discussion options

You must be logged in to vote

Firstly familiarize yourself with the body type changes in v4 explained here. Also it would be helpful to use HttpResponse from Actix Web instead of the actix-http types in your case since it contains fewer high-level things now.

Eg:

-           None => return actix_http::Response::BadRequest().body(Body::Empty),
+           None => return actix_web::HttpResponse::BadRequest().finish(),

-       actix_http::Response::Ok().json(CollectorRegisterRespone {
+       actix_web::HttpResponse::Ok().json(CollectorRegisterRespone {

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pmalek-sumo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants