Skip to content

Commit

Permalink
Rename XrpcClient method: host to base_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
sugyan committed Nov 9, 2023
1 parent b98d825 commit 29dd3b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions atrium-xrpc/src/client/reqwest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use std::error::Error;
#[derive(Debug, Default)]
pub struct ReqwestClient {
client: reqwest::Client,
host: String,
base_uri: String,
}

impl ReqwestClient {
pub fn new(host: String) -> Self {
pub fn new(base_uri: String) -> Self {
Self {
host,
base_uri,
..Default::default()
}
}
Expand All @@ -37,7 +37,7 @@ impl HttpClient for ReqwestClient {
}

impl XrpcClient for ReqwestClient {
fn host(&self) -> &str {
&self.host
fn base_uri(&self) -> &str {
&self.base_uri
}
}
6 changes: 3 additions & 3 deletions atrium-xrpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub type XrpcResult<O, E> = Result<OutputDataOrBytes<O>, self::Error<E>>;

#[async_trait]
pub trait XrpcClient: HttpClient {
fn host(&self) -> &str;
fn base_uri(&self) -> &str;
#[allow(unused_variables)]
fn auth(&self, is_refresh: bool) -> Option<String> {
None
Expand All @@ -58,7 +58,7 @@ pub trait XrpcClient: HttpClient {
O: DeserializeOwned + Send + Sync,
E: DeserializeOwned + Send + Sync,
{
let mut uri = format!("{}/xrpc/{}", self.host(), request.path);
let mut uri = format!("{}/xrpc/{}", self.base_uri(), request.path);
if let Some(p) = &request.parameters {
serde_qs::to_string(p).map(|qs| {
uri += "?";
Expand Down Expand Up @@ -135,7 +135,7 @@ mod tests {

#[async_trait]
impl XrpcClient for DummyClient {
fn host(&self) -> &str {
fn base_uri(&self) -> &str {
"https://example.com"
}
}
Expand Down

0 comments on commit 29dd3b5

Please sign in to comment.