Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add patch method to router #744

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" | "PATCH" | "DELETE" => {}
"GET" | "POST" | "PATCH" | "PUT" | "DELETE" => {}
_ => {
return Err(syn::Error::new(
req_type_ident.span(),
"Invalid endpoint request type (try GET, POST, PUT, PATCH, 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, put, and patch 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, PUT, and PATCH 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
Loading