Replace mime type "application/ron" by "text/ron" and put it in the common crate

This commit is contained in:
Greg Burri 2025-05-09 23:45:32 +02:00
parent f9899c1aeb
commit 1c2e910dea
7 changed files with 96 additions and 129 deletions

View file

@ -30,7 +30,6 @@ pub enum Error {
type Result<T> = std::result::Result<T, Error>;
const CONTENT_TYPE: &str = "Content-Type";
const CONTENT_TYPE_RON: &str = "application/ron";
async fn req_with_body<T, U>(
api_name: &str,
@ -42,7 +41,10 @@ where
U: Serialize,
{
let url = format!("/ron-api/{}", api_name);
let request_builder = method_fn(&url).header(CONTENT_TYPE, CONTENT_TYPE_RON);
let request_builder = method_fn(&url).header(
CONTENT_TYPE,
common::consts::MIME_TYPE_RON.to_str().unwrap(),
);
send_req(request_builder.body(ron_api::to_string(body)?)?).await
}
@ -57,7 +59,10 @@ where
{
let mut url = format!("/ron-api/{}?", api_name);
serde_html_form::ser::push_to_string(&mut url, params).unwrap();
let request_builder = method_fn(&url).header(CONTENT_TYPE, CONTENT_TYPE_RON);
let request_builder = method_fn(&url).header(
CONTENT_TYPE,
common::consts::MIME_TYPE_RON.to_str().unwrap(),
);
send_req(request_builder.build()?).await
}