Skip to content

Commit

Permalink
Do not assume that HTTP API prefix is always "api"
Browse files Browse the repository at this point in the history
It can be overridden and management plugin's own
test suite runs most tests both with the default
and an overridden prefix.

References #29, #30, #31
  • Loading branch information
michaelklishin committed Nov 22, 2024
1 parent bdd1d29 commit b163086
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub type Result<T> = std::result::Result<T, Error<HttpClientResponse>>;
/// ```rust
/// use rabbitmq_http_client::api::ClientBuilder;
///
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();
Expand Down Expand Up @@ -59,7 +59,7 @@ impl ClientBuilder<&'static str, &'static str, &'static str> {
pub fn new() -> Self {
let client = HttpClient::new();
Self {
endpoint: "http://localhost:15672",
endpoint: "http://localhost:15672/api",
username: "guest",
password: "guest",
client,
Expand Down Expand Up @@ -126,7 +126,7 @@ where
/// ```rust
/// use rabbitmq_http_client::api::Client;
///
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = Client::new(&endpoint, &username, &password);
Expand Down Expand Up @@ -156,7 +156,7 @@ where
/// ```rust
/// use rabbitmq_http_client::api::Client;
///
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = Client::new(endpoint, username, password);
Expand All @@ -181,7 +181,7 @@ where
/// use rabbitmq_http_client::api::Client;
///
/// let client = HttpClient::new();
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = Client::from_http_client(client, endpoint, username, password);
Expand Down
12 changes: 6 additions & 6 deletions src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub type Result<T> = std::result::Result<T, Error<HttpClientResponse>>;
/// ```rust
/// use rabbitmq_http_client::blocking::ClientBuilder;
///
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = ClientBuilder::new().with_endpoint(&endpoint).with_basic_auth_credentials(&username, &password).build();
Expand Down Expand Up @@ -127,7 +127,7 @@ where
/// ```rust
/// use rabbitmq_http_client::blocking::Client;
///
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = Client::new(&endpoint, &username, &password);
Expand Down Expand Up @@ -157,7 +157,7 @@ where
/// ```rust
/// use rabbitmq_http_client::blocking::Client;
///
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = Client::new(endpoint, username, password);
Expand All @@ -182,7 +182,7 @@ where
/// use rabbitmq_http_client::blocking::Client;
///
/// let client = HttpClient::new();
/// let endpoint = "http://localhost:15672";
/// let endpoint = "http://localhost:15672/api";
/// let username = "username";
/// let password = "password";
/// let rc = Client::from_http_client(client, endpoint, username, password);
Expand Down Expand Up @@ -1147,13 +1147,13 @@ where
where
S: AsRef<str>,
{
format!("{}/api/{}", self.endpoint, path.as_ref())
format!("{}/{}", self.endpoint, path.as_ref())
}
}

impl Default for Client<&'static str, &'static str, &'static str> {
fn default() -> Self {
Self::new("http://localhost:15672", "guest", "guest")
Self::new("http://localhost:15672/api", "guest", "guest")
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;
use std::time::Duration;

pub const ENDPOINT: &str = "http://localhost:15672";
pub const ENDPOINT: &str = "http://localhost:15672/api";
pub const USERNAME: &str = "guest";
pub const PASSWORD: &str = "guest";

Expand Down

0 comments on commit b163086

Please sign in to comment.