Add content type specification (#187)
This pr adds specifying the Content-Type header for requests with a body Should be all requests but lmk if I missed any
This commit is contained in:
commit
a9bbd51c2d
|
@ -22,7 +22,8 @@ impl Instance {
|
|||
let chorus_request = ChorusRequest {
|
||||
request: Client::new()
|
||||
.post(endpoint_url)
|
||||
.body(to_string(login_schema).unwrap()),
|
||||
.body(to_string(login_schema).unwrap())
|
||||
.header("Content-Type", "application/json"),
|
||||
limit_type: LimitType::AuthLogin,
|
||||
};
|
||||
// We do not have a user yet, and the UserRateLimits will not be affected by a login
|
||||
|
|
|
@ -27,7 +27,8 @@ impl Instance {
|
|||
let chorus_request = ChorusRequest {
|
||||
request: Client::new()
|
||||
.post(endpoint_url)
|
||||
.body(to_string(register_schema).unwrap()),
|
||||
.body(to_string(register_schema).unwrap())
|
||||
.header("Content-Type", "application/json"),
|
||||
limit_type: LimitType::AuthRegister,
|
||||
};
|
||||
// We do not have a user yet, and the UserRateLimits will not be affected by a login
|
||||
|
|
|
@ -75,6 +75,7 @@ impl Channel {
|
|||
channel_id
|
||||
))
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(to_string(&modify_data).unwrap()),
|
||||
limit_type: LimitType::Channel(channel_id),
|
||||
};
|
||||
|
@ -129,7 +130,8 @@ impl Channel {
|
|||
self.id,
|
||||
recipient_id
|
||||
))
|
||||
.header("Authorization", user.token());
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json");
|
||||
if let Some(schema) = add_channel_recipient_schema {
|
||||
request = request.body(to_string(&schema).unwrap());
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ impl Message {
|
|||
request: Client::new()
|
||||
.post(format!("{}/channels/{}/messages", url_api, channel_id))
|
||||
.header("Authorization", user.token())
|
||||
.body(to_string(&message).unwrap()),
|
||||
.body(to_string(&message).unwrap())
|
||||
.header("Content-Type", "application/json"),
|
||||
limit_type: LimitType::Channel(channel_id),
|
||||
};
|
||||
chorus_request.deserialize_response::<Message>(user).await
|
||||
|
|
|
@ -43,6 +43,7 @@ impl types::Channel {
|
|||
request: Client::new()
|
||||
.put(url)
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(body),
|
||||
limit_type: LimitType::Channel(channel_id),
|
||||
};
|
||||
|
|
|
@ -108,7 +108,10 @@ impl ReactionMeta {
|
|||
emoji
|
||||
);
|
||||
let chorus_request = ChorusRequest {
|
||||
request: Client::new().put(url).header("Authorization", user.token()),
|
||||
request: Client::new()
|
||||
.put(url)
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json"),
|
||||
limit_type: LimitType::Channel(self.channel_id),
|
||||
};
|
||||
chorus_request.handle_request_as_result(user).await
|
||||
|
|
|
@ -24,6 +24,7 @@ impl Guild {
|
|||
request: Client::new()
|
||||
.post(url.clone())
|
||||
.header("Authorization", user.token.clone())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(to_string(&guild_create_schema).unwrap()),
|
||||
limit_type: LimitType::Global,
|
||||
};
|
||||
|
@ -58,7 +59,8 @@ impl Guild {
|
|||
let chorus_request = ChorusRequest {
|
||||
request: Client::new()
|
||||
.post(url.clone())
|
||||
.header("Authorization", user.token.clone()),
|
||||
.header("Authorization", user.token.clone())
|
||||
.header("Content-Type", "application/json"),
|
||||
limit_type: LimitType::Global,
|
||||
};
|
||||
chorus_request.handle_request_as_result(user).await
|
||||
|
@ -157,6 +159,7 @@ impl Channel {
|
|||
guild_id
|
||||
))
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(to_string(&schema).unwrap()),
|
||||
limit_type: LimitType::Guild(guild_id),
|
||||
};
|
||||
|
|
|
@ -53,7 +53,10 @@ impl types::GuildMember {
|
|||
role_id
|
||||
);
|
||||
let chorus_request = ChorusRequest {
|
||||
request: Client::new().put(url).header("Authorization", user.token()),
|
||||
request: Client::new()
|
||||
.put(url)
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json"),
|
||||
limit_type: LimitType::Guild(guild_id),
|
||||
};
|
||||
chorus_request.handle_request_as_result(user).await
|
||||
|
|
|
@ -83,6 +83,7 @@ impl types::RoleObject {
|
|||
request: Client::new()
|
||||
.post(url)
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(body),
|
||||
limit_type: LimitType::Guild(guild_id),
|
||||
};
|
||||
|
@ -115,6 +116,7 @@ impl types::RoleObject {
|
|||
request: Client::new()
|
||||
.patch(url)
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(body),
|
||||
limit_type: LimitType::Guild(guild_id),
|
||||
};
|
||||
|
@ -150,6 +152,7 @@ impl types::RoleObject {
|
|||
request: Client::new()
|
||||
.patch(url)
|
||||
.header("Authorization", user.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(body),
|
||||
limit_type: LimitType::Guild(guild_id),
|
||||
};
|
||||
|
|
|
@ -31,6 +31,7 @@ impl UserMeta {
|
|||
if session_id.is_some() {
|
||||
request.request = request
|
||||
.request
|
||||
.header("Content-Type", "application/json")
|
||||
.body(to_string(session_id.unwrap()).unwrap());
|
||||
}
|
||||
request.deserialize_response::<Invite>(self).await
|
||||
|
@ -50,7 +51,8 @@ impl UserMeta {
|
|||
self.belongs_to.borrow().urls.api
|
||||
))
|
||||
.body(to_string(&code).unwrap())
|
||||
.header("Authorization", self.token()),
|
||||
.header("Authorization", self.token())
|
||||
.header("Content-Type", "application/json"),
|
||||
limit_type: super::LimitType::Global,
|
||||
}
|
||||
.deserialize_response::<Invite>(self)
|
||||
|
@ -77,6 +79,7 @@ impl UserMeta {
|
|||
channel_id
|
||||
))
|
||||
.header("Authorization", self.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(to_string(&create_channel_invite_schema).unwrap()),
|
||||
limit_type: super::LimitType::Channel(channel_id),
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ impl UserMeta {
|
|||
request: Client::new()
|
||||
.post(url)
|
||||
.header("Authorization", self.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(to_string(&create_private_channel_schema).unwrap()),
|
||||
limit_type: LimitType::Global,
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ impl UserMeta {
|
|||
guild_id
|
||||
))
|
||||
.header("Authorization", self.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(to_string(&lurking).unwrap()),
|
||||
limit_type: crate::api::LimitType::Guild(*guild_id),
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ impl UserMeta {
|
|||
request: Client::new()
|
||||
.post(url)
|
||||
.header("Authorization", self.token())
|
||||
.header("Content-Type", "application/json")
|
||||
.body(body),
|
||||
limit_type: LimitType::Global,
|
||||
};
|
||||
|
|
|
@ -50,7 +50,8 @@ impl UserMeta {
|
|||
let request = Client::new()
|
||||
.patch(format!("{}/users/@me", self.belongs_to.borrow().urls.api))
|
||||
.body(to_string(&modify_schema).unwrap())
|
||||
.header("Authorization", self.token());
|
||||
.header("Authorization", self.token())
|
||||
.header("Content-Type", "application/json");
|
||||
let chorus_request = ChorusRequest {
|
||||
request,
|
||||
limit_type: LimitType::default(),
|
||||
|
@ -68,7 +69,8 @@ impl UserMeta {
|
|||
"{}/users/@me/delete",
|
||||
self.belongs_to.borrow().urls.api
|
||||
))
|
||||
.header("Authorization", self.token());
|
||||
.header("Authorization", self.token())
|
||||
.header("Content-Type", "application/json");
|
||||
let chorus_request = ChorusRequest {
|
||||
request,
|
||||
limit_type: LimitType::default(),
|
||||
|
|
Loading…
Reference in New Issue