pub struct Client {
pub base_path: String,
pub http_client: Client,
pub api_token: String,
}
Expand description
Configuration for the Bitbucket Server API HTTP client.
This struct holds all the necessary configuration for making API requests to a Bitbucket Server instance.
Fields§
§base_path: String
Base URL for the bitbucket server. It must end with /rest
.
http_client: Client
The HTTP client to use for making requests.
api_token: String
The API token to use for authentication.
Implementations§
Source§impl Client
HTTP request and response handling implementations for the Bitbucket API client.
impl Client
HTTP request and response handling implementations for the Bitbucket API client.
Sourcepub async fn builder(&self, req: RequestBuilder) -> RequestBuilder
pub async fn builder(&self, req: RequestBuilder) -> RequestBuilder
Sourcepub fn with_http_client(&mut self, http_client: Client)
pub fn with_http_client(&mut self, http_client: Client)
Set a custom HTTP client with specific configuration.
This method allows you to use a custom HTTP client with specific configuration options, such as timeouts, proxies, etc.
§Arguments
http_client
- The custom HTTP client to use.
§Example
use bitbucket_server_rs::client::new;
use reqwest::ClientBuilder;
use std::time::Duration;
let mut client = new("https://bitbucket-server/rest", "API_TOKEN");
// Create a custom HTTP client with a 30-second timeout
let http_client = ClientBuilder::new()
.timeout(Duration::from_secs(30))
.build()
.expect("Failed to build HTTP client");
// Set the custom HTTP client
client.with_http_client(http_client);
Sourcepub async fn get<T: ApiRequest>(
&self,
uri: &str,
params: Option<HashMap<String, String>>,
) -> ApiResponse<T::Output>
pub async fn get<T: ApiRequest>( &self, uri: &str, params: Option<HashMap<String, String>>, ) -> ApiResponse<T::Output>
Send a GET request to the Bitbucket Server API.
This method sends a GET request to the specified URI with the given query parameters.
§Arguments
uri
- The URI to send the request to, relative to the base path.params
- Optional query parameters to include in the request.
§Returns
A Result containing either the response data or an error.
Sourcepub async fn post<T: ApiRequest>(
&self,
uri: &str,
body: &str,
) -> ApiResponse<<T as ApiRequest>::Output>
pub async fn post<T: ApiRequest>( &self, uri: &str, body: &str, ) -> ApiResponse<<T as ApiRequest>::Output>
Send a POST request to the Bitbucket Server API.
This method sends a POST request to the specified URI with the given body.
§Arguments
uri
- The URI to send the request to, relative to the base path.body
- The body to include in the request.
§Returns
A Result containing either the response data or an error.