diff --git a/Cargo.toml b/Cargo.toml index 9f0209f4..71c75b6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,9 @@ members = [ [dependencies] ya-client-model = { version= "^0.4", path = "model" } -awc = "2.0" -actix-codec = "0.3" -bytes = "0.5" +awc = "3" +actix-codec = "0.5" +bytes = "1" chrono = "0.4" envy = "0.4" futures = "0.3" @@ -32,22 +32,22 @@ heck = "0.3.1" log = "0.4" rand = "0.6" mime = "0.3" -serde = "1.0" +serde = "1" serde_json = "1.0" serde_qs = "0.8" -thiserror = "1.0" -url = "2.1" +thiserror = "1" +url = "2" graphene-sgx = { version = "0.3.3", optional = true } lazy_static = { version = "1.4", optional = true } secp256k1 = { version = "0.19", optional = true } -structopt = { version = "0.3.12", optional = true } +structopt = { version = "0.3", optional = true } openssl = { version = "0.10", optional = true } [dev-dependencies] -actix-rt = "1.1" +actix-rt = "2.7.0" anyhow = "1.0" -env_logger = "0.7" +env_logger = "0.9" structopt = "0.3" [package.metadata.release] diff --git a/model/Cargo.toml b/model/Cargo.toml index 75c898da..9be16381 100644 --- a/model/Cargo.toml +++ b/model/Cargo.toml @@ -16,10 +16,10 @@ sgx = ['secp256k1', 'openssl', 'hex', 'secp256k1/serde'] [dependencies] bigdecimal = { version = "0.2", features = ["serde"]} chrono = { version = "0.4", features = ["serde"]} -derive_more = "0.99.11" -rand = "0.7.3" -serde = { version = "^1.0", features = ["derive"] } -serde_json = "^1.0" +derive_more = "0.99" +rand = "0.8" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" strum = "0.19" strum_macros = "0.19" thiserror = "1.0" diff --git a/model/src/activity.rs b/model/src/activity.rs index 35cfab75..2c1a2ae0 100644 --- a/model/src/activity.rs +++ b/model/src/activity.rs @@ -25,4 +25,4 @@ pub use self::runtime_event::{RuntimeEvent, RuntimeEventKind}; #[cfg(feature = "sgx")] pub use self::sgx_credentials::SgxCredentials; -pub const ACTIVITY_API_PATH: &str = "/activity-api/v1/"; +pub const ACTIVITY_API_PATH: &str = "/activity-api/v1"; diff --git a/model/src/market.rs b/model/src/market.rs index cf162ad5..57ae70ea 100644 --- a/model/src/market.rs +++ b/model/src/market.rs @@ -20,4 +20,4 @@ pub use property_query::PropertyQuery; pub use proposal::Proposal; pub use reason::Reason; -pub const MARKET_API_PATH: &str = "market-api/v1/"; +pub const MARKET_API_PATH: &str = "/market-api/v1"; diff --git a/model/src/net.rs b/model/src/net.rs index c0e3e48d..906acd76 100644 --- a/model/src/net.rs +++ b/model/src/net.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -pub const NET_API_PATH: &str = "/net-api/v1/"; +pub const NET_API_PATH: &str = "/net-api/v1"; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/model/src/payment.rs b/model/src/payment.rs index b53bac0f..cbf3826e 100644 --- a/model/src/payment.rs +++ b/model/src/payment.rs @@ -37,4 +37,4 @@ pub use self::payment::Payment; pub use self::rejection::Rejection; pub use self::rejection_reason::RejectionReason; -pub const PAYMENT_API_PATH: &str = "payment-api/v1/"; +pub const PAYMENT_API_PATH: &str = "/payment-api/v1"; diff --git a/src/web.rs b/src/web.rs index f581241f..c4207eb4 100644 --- a/src/web.rs +++ b/src/web.rs @@ -2,11 +2,12 @@ use actix_codec::Framed; use awc::{ error::{PayloadError, SendRequestError}, - http::{header, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}, + http::header::{HeaderMap, HeaderName, HeaderValue}, + http::{header, Method, StatusCode}, ws::Codec, BoxedSocket, ClientRequest, ClientResponse, SendClientRequest, }; -use bytes::{Buf, Bytes, BytesMut}; +use bytes::{Bytes, BytesMut}; use futures::stream::Peekable; use futures::{Stream, StreamExt, TryStreamExt}; use heck::MixedCase; @@ -54,7 +55,8 @@ pub trait WebInterface { if let Some(url) = std::env::var(Self::API_URL_ENV_VAR).ok() { return Ok(Url::from_str(&url)?.into()); } - Ok(base_url.join(Self::API_SUFFIX)?.into()) + let with_trailing = format!("{}/", Self::API_SUFFIX); + Ok(base_url.join(&with_trailing)?.into()) } fn from_client(client: WebClient) -> Self; @@ -117,7 +119,7 @@ impl WebClient { let request = self .awc .request(method.clone(), &url) - .set(header::Accept(vec![header::qitem(mime::TEXT_EVENT_STREAM)])); + .insert_header((header::ACCEPT, mime::TEXT_EVENT_STREAM)); let stream = request .send() .await @@ -319,7 +321,7 @@ impl WebClientBuilder { } } for (key, value) in self.headers.iter() { - builder = builder.header(key.clone(), value.clone()); + builder = builder.add_default_header((key.clone(), value.clone())); } WebClient { @@ -446,7 +448,7 @@ where fn next_event(&mut self, start_idx: usize) -> Option> { let idx = max(0, start_idx as i64 - 1) as usize; - if let Some(idx) = Self::find(self.buffer.bytes(), b"\n\n", idx) { + if let Some(idx) = Self::find(&self.buffer, b"\n\n", idx) { let bytes = self.buffer.split_to(idx); return String::from_utf8(bytes.to_vec()) .map(Event::try_from)