api-macros: Small improvements to request building code

This commit is contained in:
Jonas Platte 2020-09-17 21:46:46 +02:00
parent b4b9d28c8c
commit 133056c524
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 4 additions and 4 deletions

View File

@ -135,8 +135,8 @@ impl ToTokens for Api {
let mut header_kvs = self.request.append_header_kvs();
if requires_authentication.value {
header_kvs.push(quote! {
let req_builder = req_builder.header(
header_kvs.extend(quote! {
req_builder = req_builder.header(
#ruma_api_import::exports::http::header::AUTHORIZATION,
#ruma_api_import::exports::http::header::HeaderValue::from_str(
&::std::format!(
@ -353,7 +353,7 @@ impl ToTokens for Api {
#request_query_string,
));
#( #header_kvs )*
#header_kvs
let http_request = req_builder.body(#request_body)?;

View File

@ -39,7 +39,7 @@ pub struct Request {
impl Request {
/// Produces code to add necessary HTTP headers to an `http::Request`.
pub fn append_header_kvs(&self) -> Vec<TokenStream> {
pub fn append_header_kvs(&self) -> TokenStream {
let import_path = &self.ruma_api_import;
self.header_fields().map(|request_field| {
let (field, header_name) = match request_field {