Fix another bug and use a more useful variable name for named path segments.

This commit is contained in:
Jimmy Cuadra 2018-05-13 00:09:39 -07:00
parent 38746660b6
commit c86cdb29b3

View File

@ -70,13 +70,7 @@ impl ToTokens for Api {
}; };
let set_request_path = if self.request.has_path_fields() { let set_request_path = if self.request.has_path_fields() {
let path_str_quoted = path.as_str(); let path_str = path.as_str();
assert!(
path_str_quoted.starts_with('"') && path_str_quoted.ends_with('"'),
"path needs to be a string literal"
);
let path_str = &path_str_quoted[1 .. path_str_quoted.len() - 1];
assert!(path_str.starts_with('/'), "path needs to start with '/'"); assert!(path_str.starts_with('/'), "path needs to start with '/'");
assert!( assert!(
@ -103,10 +97,10 @@ impl ToTokens for Api {
}); });
if segment.starts_with(':') { if segment.starts_with(':') {
let what_is_this = &segment[1..]; let path_var = &segment[1..];
tokens.append_all(quote! { tokens.append_all(quote! {
(&request_path.#what_is_this.to_string()); (&request_path.#path_var.to_string());
}); });
} else { } else {
tokens.append_all(quote! { tokens.append_all(quote! {