ic_http_gateway/client/
http_gateway_client_builder.rs1use crate::{
2 HttpGatewayClient, HttpGatewayClientArgs, HttpGatewayResult, DEFAULT_BOUNDARY_NODE_ENDPOINT,
3};
4use ic_agent::Agent;
5
6pub struct HttpGatewayClientBuilder {
7 agent: Option<Agent>,
8}
9
10impl HttpGatewayClientBuilder {
11 pub fn new() -> Self {
12 Self { agent: None }
13 }
14
15 pub fn with_agent(mut self, agent: Agent) -> Self {
16 self.agent = Some(agent);
17
18 self
19 }
20
21 pub fn build(self) -> HttpGatewayResult<HttpGatewayClient> {
22 let agent = match self.agent {
23 Some(agent) => agent,
24 None => Agent::builder()
25 .with_url(DEFAULT_BOUNDARY_NODE_ENDPOINT)
26 .build()?,
27 };
28
29 Ok(HttpGatewayClient::new(HttpGatewayClientArgs { agent }))
30 }
31}
32
33impl Default for HttpGatewayClientBuilder {
34 fn default() -> Self {
35 Self::new()
36 }
37}