Skip to content

Commit

Permalink
add other http methods (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
tl-flavio-barinas committed Mar 6, 2024
1 parent 904d429 commit 8c41017
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions rust/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ use std::{
pub enum Method {
Get,
Post,
Put,
Delete,
Patch,
}

impl Method {
pub const fn name(self) -> &'static str {
match self {
Method::Get => "GET",
Method::Post => "POST",
Method::Put => "PUT",
Method::Delete => "DELETE",
Method::Patch => "PATCH",
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions rust/src/sign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ impl<'a, K, Pk, Path> SignerBuilder<'a, K, Pk, &'a [u8], Unset, Path> {
kid: self.kid,
private_key: self.private_key,
body: match method {
Method::Get => &[],
Method::Post => self.body,
Method::Get | Method::Delete => &[],
Method::Post | Method::Put | Method::Patch => self.body,
},
method,
path: self.path,
Expand Down Expand Up @@ -214,8 +214,8 @@ impl<'a> SignerBuilder<'a, &'a str, Unset, &'a [u8], Method, &'a str> {
CustomSigner {
kid: self.kid,
body: match self.method {
Method::Get => &[],
Method::Post => self.body,
Method::Get | Method::Delete => &[],
Method::Post | Method::Put | Method::Patch => self.body,
},
method: self.method.name(),
path: self.path,
Expand Down Expand Up @@ -252,8 +252,8 @@ impl<'a> SignerBuilder<'a, &'a str, &'a [u8], &'a [u8], Method, &'a str> {
base: CustomSigner {
kid: self.kid,
body: match self.method {
Method::Get => &[],
Method::Post => self.body,
Method::Get | Method::Delete => &[],
Method::Post | Method::Put | Method::Patch => self.body,
},
method: self.method.name(),
path: self.path,
Expand Down
4 changes: 2 additions & 2 deletions rust/src/verify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ impl<'a> VerifierBuilder<'a, PublicKey<'a>, &'a [u8], Method, &'a str> {
Verifier {
base: CustomVerifier {
body: match self.method {
Method::Get => &[],
Method::Post => self.body,
Method::Get | Method::Delete => &[],
Method::Post | Method::Put | Method::Patch => self.body,
},
method: self.method.name(),
path: self.path,
Expand Down

0 comments on commit 8c41017

Please sign in to comment.