pub trait HttpClient: Send + Sync {
// Required methods
fn get_bytes(&self, url: &str) -> Result<Vec<u8>, SkillfileError>;
fn get_json(&self, url: &str) -> Result<Option<String>, SkillfileError>;
fn post_json(
&self,
url: &str,
body: &str,
) -> Result<Vec<u8>, SkillfileError>;
// Provided method
fn post_json_with_bearer(
&self,
req: &BearerPost<'_>,
) -> Result<Vec<u8>, SkillfileError> { ... }
}Expand description
Contract for HTTP GET requests used by the fetcher/resolver layer.
Implementations are responsible for:
- Setting standard headers (User-Agent, Authorization)
- Connection pooling / agent reuse
- Error mapping to
SkillfileError
The trait has three methods covering the HTTP patterns in this codebase:
get_bytes: raw file downloads (content fromraw.githubusercontent.com)get_json: GitHub API calls that may return 4xx gracefullypost_json: POST with JSON body (used by some registry APIs)
Required Methods§
Sourcefn get_bytes(&self, url: &str) -> Result<Vec<u8>, SkillfileError>
fn get_bytes(&self, url: &str) -> Result<Vec<u8>, SkillfileError>
Returns Err(SkillfileError::Network) on HTTP errors (including 404).
Provided Methods§
Sourcefn post_json_with_bearer(
&self,
req: &BearerPost<'_>,
) -> Result<Vec<u8>, SkillfileError>
fn post_json_with_bearer( &self, req: &BearerPost<'_>, ) -> Result<Vec<u8>, SkillfileError>
POST with a custom Authorization: Bearer header (for non-GitHub APIs).
Default: ignores the token and delegates to post_json.
Test mocks use this default; UreqClient overrides to send the header.
§Note
The extra token parameter is required by non-GitHub registry APIs (e.g.
skillhub.club).