mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
Export ws sub-module with websockets related types
This commit is contained in:
parent
709475b2bb
commit
058b1d56e6
@ -1,6 +1,6 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [0.1.0-alpha.2] - 2019-04-xx
|
## [0.1.0-alpha.2] - 2019-03-xx
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
@ -12,6 +12,10 @@
|
|||||||
|
|
||||||
* Session wide basic and bearer auth.
|
* Session wide basic and bearer auth.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Export `ws` sub-module with websockets related types
|
||||||
|
|
||||||
|
|
||||||
## [0.1.0-alpha.1] - 2019-03-28
|
## [0.1.0-alpha.1] - 2019-03-28
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! Http client errors
|
//! Http client errors
|
||||||
pub use actix_http::client::{ConnectError, InvalidUrl, SendRequestError};
|
pub use actix_http::client::{ConnectError, InvalidUrl, SendRequestError};
|
||||||
pub use actix_http::error::PayloadError;
|
pub use actix_http::error::PayloadError;
|
||||||
|
pub use actix_http::ws::HandshakeError as WsHandshakeError;
|
||||||
pub use actix_http::ws::ProtocolError as WsProtocolError;
|
pub use actix_http::ws::ProtocolError as WsProtocolError;
|
||||||
|
|
||||||
use actix_http::http::{header::HeaderValue, Error as HttpError, StatusCode};
|
use actix_http::http::{header::HeaderValue, Error as HttpError, StatusCode};
|
||||||
|
@ -35,12 +35,11 @@ pub mod error;
|
|||||||
mod request;
|
mod request;
|
||||||
mod response;
|
mod response;
|
||||||
pub mod test;
|
pub mod test;
|
||||||
mod ws;
|
pub mod ws;
|
||||||
|
|
||||||
pub use self::builder::ClientBuilder;
|
pub use self::builder::ClientBuilder;
|
||||||
pub use self::request::ClientRequest;
|
pub use self::request::ClientRequest;
|
||||||
pub use self::response::ClientResponse;
|
pub use self::response::ClientResponse;
|
||||||
pub use self::ws::WebsocketsRequest;
|
|
||||||
|
|
||||||
use self::connect::{Connect, ConnectorWrapper};
|
use self::connect::{Connect, ConnectorWrapper};
|
||||||
|
|
||||||
@ -126,6 +125,7 @@ impl Client {
|
|||||||
req
|
req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct HTTP *GET* request.
|
||||||
pub fn get<U>(&self, url: U) -> ClientRequest
|
pub fn get<U>(&self, url: U) -> ClientRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
@ -133,6 +133,7 @@ impl Client {
|
|||||||
self.request(Method::GET, url)
|
self.request(Method::GET, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct HTTP *HEAD* request.
|
||||||
pub fn head<U>(&self, url: U) -> ClientRequest
|
pub fn head<U>(&self, url: U) -> ClientRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
@ -140,6 +141,7 @@ impl Client {
|
|||||||
self.request(Method::HEAD, url)
|
self.request(Method::HEAD, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct HTTP *PUT* request.
|
||||||
pub fn put<U>(&self, url: U) -> ClientRequest
|
pub fn put<U>(&self, url: U) -> ClientRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
@ -147,6 +149,7 @@ impl Client {
|
|||||||
self.request(Method::PUT, url)
|
self.request(Method::PUT, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct HTTP *POST* request.
|
||||||
pub fn post<U>(&self, url: U) -> ClientRequest
|
pub fn post<U>(&self, url: U) -> ClientRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
@ -154,6 +157,7 @@ impl Client {
|
|||||||
self.request(Method::POST, url)
|
self.request(Method::POST, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct HTTP *PATCH* request.
|
||||||
pub fn patch<U>(&self, url: U) -> ClientRequest
|
pub fn patch<U>(&self, url: U) -> ClientRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
@ -161,6 +165,7 @@ impl Client {
|
|||||||
self.request(Method::PATCH, url)
|
self.request(Method::PATCH, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct HTTP *DELETE* request.
|
||||||
pub fn delete<U>(&self, url: U) -> ClientRequest
|
pub fn delete<U>(&self, url: U) -> ClientRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
@ -168,6 +173,7 @@ impl Client {
|
|||||||
self.request(Method::DELETE, url)
|
self.request(Method::DELETE, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct HTTP *OPTIONS* request.
|
||||||
pub fn options<U>(&self, url: U) -> ClientRequest
|
pub fn options<U>(&self, url: U) -> ClientRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
@ -175,11 +181,12 @@ impl Client {
|
|||||||
self.request(Method::OPTIONS, url)
|
self.request(Method::OPTIONS, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ws<U>(&self, url: U) -> WebsocketsRequest
|
/// Construct WebSockets request.
|
||||||
|
pub fn ws<U>(&self, url: U) -> ws::WebsocketsRequest
|
||||||
where
|
where
|
||||||
Uri: HttpTryFrom<U>,
|
Uri: HttpTryFrom<U>,
|
||||||
{
|
{
|
||||||
let mut req = WebsocketsRequest::new(url, self.0.clone());
|
let mut req = ws::WebsocketsRequest::new(url, self.0.clone());
|
||||||
for (key, value) in &self.0.headers {
|
for (key, value) in &self.0.headers {
|
||||||
req.head.headers.insert(key.clone(), value.clone());
|
req.head.headers.insert(key.clone(), value.clone());
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ use cookie::{Cookie, CookieJar};
|
|||||||
use futures::future::{err, Either, Future};
|
use futures::future::{err, Either, Future};
|
||||||
use tokio_timer::Timeout;
|
use tokio_timer::Timeout;
|
||||||
|
|
||||||
|
pub use actix_http::ws::{CloseCode, CloseReason, Frame, Message};
|
||||||
|
|
||||||
use crate::connect::BoxedSocket;
|
use crate::connect::BoxedSocket;
|
||||||
use crate::error::{InvalidUrl, SendRequestError, WsClientError};
|
use crate::error::{InvalidUrl, SendRequestError, WsClientError};
|
||||||
use crate::http::header::{
|
use crate::http::header::{
|
||||||
@ -208,7 +210,7 @@ impl WebsocketsRequest {
|
|||||||
self.header(AUTHORIZATION, format!("Bearer {}", token))
|
self.header(AUTHORIZATION, format!("Bearer {}", token))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Complete request construction and connect.
|
/// Complete request construction and connect to a websockets server.
|
||||||
pub fn connect(
|
pub fn connect(
|
||||||
mut self,
|
mut self,
|
||||||
) -> impl Future<
|
) -> impl Future<
|
||||||
|
Loading…
Reference in New Issue
Block a user