mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Add content-type header to BRP HTTP responses (#15552)
This makes HTTP clients like httpie format the response as JSON rather than text for a much nicer experience testing things.
This commit is contained in:
parent
429987ebf8
commit
10068f4a26
1 changed files with 7 additions and 3 deletions
|
@ -19,6 +19,7 @@ use core::net::{IpAddr, Ipv4Addr};
|
|||
use http_body_util::{BodyExt as _, Full};
|
||||
use hyper::{
|
||||
body::{Bytes, Incoming},
|
||||
header::HeaderValue,
|
||||
server::conn::http1,
|
||||
service, Request, Response,
|
||||
};
|
||||
|
@ -192,9 +193,12 @@ async fn process_request_batch(
|
|||
}
|
||||
};
|
||||
|
||||
Ok(Response::new(Full::new(Bytes::from(
|
||||
serialized.as_bytes().to_owned(),
|
||||
))))
|
||||
let mut response = Response::new(Full::new(Bytes::from(serialized.as_bytes().to_owned())));
|
||||
response.headers_mut().insert(
|
||||
hyper::header::CONTENT_TYPE,
|
||||
HeaderValue::from_static("application/json"),
|
||||
);
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
/// A helper function for the Bevy Remote Protocol server that processes a single
|
||||
|
|
Loading…
Reference in a new issue