Previously, there were impl TryFrom<Json> for Body and impl IntoResponse for T where T: TryInto<Body>, so Json was deduced as impl IntoResponse. However, Content-Type was not inserted in IntoResponse, which may cause problems.
Solution
This PR implements IntoResponse for Json and Form, and inserts Content-Type in the header. To avoid compilation issues, TryFrom<Json<T>> for Body has been removed. When the client needs to send json, users can call json directly without calling data and manually inserting the header.
Motivation
Previously, there were
impl TryFrom<Json> for Body
andimpl IntoResponse for T where T: TryInto<Body>
, soJson
was deduced asimpl IntoResponse
. However,Content-Type
was not inserted inIntoResponse
, which may cause problems.Solution
This PR implements
IntoResponse
forJson
andForm
, and insertsContent-Type
in the header. To avoid compilation issues,TryFrom<Json<T>> for Body
has been removed. When the client needs to send json, users can calljson
directly without callingdata
and manually inserting the header.