Skip to content

Commit

Permalink
Include a Content-Type header when posting (closes #18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Sep 27, 2024
1 parent aa70798 commit c8bec4e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/core/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,11 @@ impl<'x> HttpRequest {
self
}

pub fn with_body<B: Serialize>(mut self, body: B) -> Result<Self> {
pub fn with_body<B: Serialize>(self, body: B) -> Result<Self> {
match serde_json::to_string(&body) {
Ok(body) => {
self.body = Some(body);
Ok(self)
}
Ok(body) => Ok(self
.with_raw_body(body)
.with_header("Content-Type", "application/json")),
Err(err) => Err(Error::Serializer {
error: err.to_string(),
response: "".to_string(),
Expand Down

0 comments on commit c8bec4e

Please sign in to comment.