Skip to content

Commit

Permalink
feat: add patch method to router
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Apr 25, 2024
1 parent 5b1de57 commit 16aead3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/api-helper/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,11 @@ impl Parse for EndpointFunction {
let req_type = req_type_ident.to_string();

match req_type.as_str() {
"GET" | "POST" | "PUT" | "DELETE" => {}
"GET" | "POST" | "PATCH" | "PUT" | "DELETE" => {}
_ => {
return Err(syn::Error::new(
req_type_ident.span(),
"Invalid endpoint request type (try GET, POST, PUT, DELETE)",
"Invalid endpoint request type (must be GET, POST, PATCH, PUT, or DELETE)",
));
}
};
Expand Down Expand Up @@ -609,7 +609,7 @@ impl Parse for EndpointFunction {
.map(|arg| arg.value.expect_expr().cloned())
.transpose()?;

// Make sure body is set for post and put requests
// Make sure body is set for post, patch, and put requests
if body.is_none()
&& !args
.iter()
Expand All @@ -618,7 +618,7 @@ impl Parse for EndpointFunction {
if req_type != "GET" && req_type != "DELETE" {
return Err(syn::Error::new(
args_tt.span,
"POST and PUT endpoints must have a body argument",
"POST, PATCH, and PUT endpoints must have a body argument",
));
}
} else if req_type == "DELETE" || req_type == "GET" {
Expand Down
1 change: 1 addition & 0 deletions lib/api-helper/macros/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ pub fn default_rate_limit_key(path: &syn::Path) -> String {
pub fn default_rate_limit_bucket(req_type: String) -> TokenStream2 {
let count: u64 = match req_type.as_str() {
"GET" => 128,
"PATCH" => 32,
"POST" | "PUT" | "DELETE" => 16,
_ => 16,
};
Expand Down

0 comments on commit 16aead3

Please sign in to comment.