Skip to content

Commit

Permalink
parse Url early
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx committed Sep 11, 2024
1 parent 5d3c104 commit b7d293c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crates/context/config/src/client/relayer.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
use std::borrow::Cow;

use serde::{Deserialize, Serialize};
use url::Url;

use super::{Operation, Transport, TransportRequest};

#[derive(Debug)]
pub struct RelayerConfig<'a> {
pub url: Cow<'a, str>,
pub struct RelayerConfig {
pub url: Url,
}

#[derive(Debug)]
pub struct RelayerTransport<'a> {
pub struct RelayerTransport {
client: reqwest::Client,
url: Cow<'a, str>,
url: Url,
}

impl<'a> RelayerTransport<'a> {
pub fn new(config: &RelayerConfig<'a>) -> Self {
impl RelayerTransport {
pub fn new(config: &RelayerConfig) -> Self {
let client = reqwest::Client::new();

Self {
Expand All @@ -34,7 +35,7 @@ pub struct RelayRequest<'a> {
pub payload: Vec<u8>,
}

impl Transport for RelayerTransport<'_> {
impl Transport for RelayerTransport {
type Error = reqwest::Error;

async fn send(
Expand All @@ -44,7 +45,7 @@ impl Transport for RelayerTransport<'_> {
) -> Result<Vec<u8>, Self::Error> {
let response = self
.client
.post(&*self.url)
.post(self.url.clone())
.json(&RelayRequest {
network_id: request.network_id,
contract_id: request.contract_id,
Expand Down

0 comments on commit b7d293c

Please sign in to comment.