-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add FileRead and HttpSend (#484)
Signed-off-by: Xuanwo <[email protected]>
- Loading branch information
Showing
5 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use anyhow::Result; | ||
|
||
/// FileRead is used to read the file content entirely in `Vec<u8>`. | ||
/// | ||
/// This could be used by `Load` to load the credential from the file. | ||
#[async_trait::async_trait] | ||
pub trait FileRead { | ||
/// Read the file content entirely in `Vec<u8>`. | ||
async fn file_read(&self, path: &str) -> Result<Vec<u8>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use anyhow::Result; | ||
use bytes::Bytes; | ||
|
||
/// HttpSend is used to send http request during the signing process. | ||
/// | ||
/// For example, fetch IMDS token from AWS or OAuth2 refresh token. This trait is designed | ||
/// especially for the signer, please don't use it as a general http client. | ||
#[async_trait::async_trait] | ||
pub trait HttpSend { | ||
/// Send http request and return the response. | ||
async fn http_send(&self, req: http::Request<Bytes>) -> Result<http::Response<Bytes>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters