-
Notifications
You must be signed in to change notification settings - Fork 222
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
refactor: refactor the resource reader #2290
refactor: refactor the resource reader #2290
Conversation
let response = reader.get(&url, headers).await?; | ||
input_samples.push(Input::Json { url: url.parse()?, response, field_name }); | ||
let mut request = reqwest::Request::new(reqwest::Method::GET, url.parse()?); | ||
if let Some(headers_inner) = headers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do something better for this else we've to convert the BTreeMap to HeaderMap.
can use TryFrom trait.
src/core/resource_reader.rs
Outdated
.execute(reqwest::Request::new(reqwest::Method::GET, url)) | ||
.await?; | ||
|
||
async fn read<T: Into<Resource> + ToString + Send>(&self, file: T) -> anyhow::Result<FileRead> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async fn read<T: Into<Resource> + ToString + Send>(&self, file: T) -> anyhow::Result<FileRead> { | |
async fn read<T: Into<Resource> + Send>(&self, file: T) -> anyhow::Result<FileRead> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/core/resource_reader.rs
Outdated
@@ -16,48 +14,73 @@ pub struct FileRead { | |||
pub path: String, | |||
} | |||
|
|||
/// Supported Resources by Resource Reader | |||
pub enum Resource { | |||
File(String), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File(String), | |
RawPath(String), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
a1d5c2e
into
feat/add-support-for-headers-in-request
Summary:
Briefly describe the changes made in this PR.
Issue Reference(s):
Fixes #... (Replace "..." with the issue number)
Build & Testing:
cargo test
successfully../lint.sh --mode=fix
to fix all linting issues raised by./lint.sh --mode=check
.Checklist:
<type>(<optional scope>): <title>