Skip to content

Commit e93c4bc

Browse files
committed
Include request in get_headers
1 parent 23eddd6 commit e93c4bc

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
130130
let request_body = request.encode_to_vec();
131131
let headers = self
132132
.header_provider
133-
.get_headers()
133+
.get_headers(&request_body)
134134
.await
135135
.map_err(|e| VssError::InternalError(e.to_string()))?;
136136
let headermap = get_headermap(&headers).map_err(VssError::InternalError)?;

src/headers/lnurl_auth_jwt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl LnurlAuthJwt {
139139

140140
#[async_trait]
141141
impl VssHeaderProvider for LnurlAuthJwt {
142-
async fn get_headers(&self) -> Result<HashMap<String, String>, VssError> {
142+
async fn get_headers(&self, _request: &[u8]) -> Result<HashMap<String, String>, VssError> {
143143
let jwt_token = self.get_jwt_token(false).await?;
144144
let mut headers = self.default_headers.clone();
145145
headers.insert(AUTHORIZATION.to_string(), format!("Bearer {}", jwt_token));

src/headers/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use lnurl_auth_jwt::LnurlAuthJwt;
1515
pub trait VssHeaderProvider {
1616
/// Returns the HTTP headers to be used for a VSS request.
1717
/// This method is called on each request, and should likely perform some form of caching.
18-
async fn get_headers(&self) -> Result<HashMap<String, String>, VssError>;
18+
async fn get_headers(&self, request: &[u8]) -> Result<HashMap<String, String>, VssError>;
1919
}
2020

2121
/// A header provider returning an given, fixed set of headers.
@@ -32,7 +32,7 @@ impl FixedHeaders {
3232

3333
#[async_trait]
3434
impl VssHeaderProvider for FixedHeaders {
35-
async fn get_headers(&self) -> Result<HashMap<String, String>, VssError> {
35+
async fn get_headers(&self, _request: &[u8]) -> Result<HashMap<String, String>, VssError> {
3636
Ok(self.headers.clone())
3737
}
3838
}

tests/lnurl_auth_jwt_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod lnurl_auth_jwt_tests {
5656
.with_body(lnurl_auth_response(&expired_jwt))
5757
.create();
5858
assert_eq!(
59-
lnurl_auth_jwt.get_headers().await.unwrap().get("authorization").unwrap(),
59+
lnurl_auth_jwt.get_headers(&[]).await.unwrap().get("authorization").unwrap(),
6060
&format!("Bearer {}", expired_jwt),
6161
);
6262
lnurl.assert();
@@ -86,11 +86,11 @@ mod lnurl_auth_jwt_tests {
8686
.with_body(lnurl_auth_response(&valid_jwt))
8787
.create();
8888
assert_eq!(
89-
lnurl_auth_jwt.get_headers().await.unwrap().get("authorization").unwrap(),
89+
lnurl_auth_jwt.get_headers(&[]).await.unwrap().get("authorization").unwrap(),
9090
&format!("Bearer {}", valid_jwt),
9191
);
9292
assert_eq!(
93-
lnurl_auth_jwt.get_headers().await.unwrap().get("authorization").unwrap(),
93+
lnurl_auth_jwt.get_headers(&[]).await.unwrap().get("authorization").unwrap(),
9494
&format!("Bearer {}", valid_jwt),
9595
);
9696
lnurl.assert();

0 commit comments

Comments
 (0)