in api_generator/src/generator/code_gen/request/request_builder.rs [84:119]
fn create_method_expression(builder_name: &str, endpoint: &ApiEndpoint) -> syn::Expr {
let methods = {
let mut m = Vec::new();
for path in &endpoint.url.paths {
for method in &path.methods {
if !m.contains(&method) {
m.push(method);
}
}
}
m
};
match methods.len() {
1 => {
let method = *methods.first().unwrap();
let mut tokens = Tokens::new();
method.to_tokens(&mut tokens);
parse_expr(tokens)
}
_ => match methods.as_slice() {
[HttpMethod::Post, HttpMethod::Put] => {
if builder_name.contains("Put") {
parse_expr(quote!(http::Method::Put))
} else {
parse_expr(quote!(http::Method::Post))
}
}
[HttpMethod::Get, HttpMethod::Post] => parse_expr(quote!(match self.body {
Some(_) => http::Method::Post,
None => http::Method::Get,
})),
_ => panic!("Combination of methods unexpected"),
},
}
}