api-macros: Small improvements to request building code
This commit is contained in:
parent
b4b9d28c8c
commit
133056c524
@ -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)?;
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user