Skip to content

Commit

Permalink
Add version string function
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Nov 2, 2018
1 parent e8986cf commit 2264095
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,21 @@ pub use client::Client;
pub use error::Error;
pub use options::*;


/// Gets a human-readable string with the version number of cHTTP and its dependencies.
///
/// This function can be helpful when troubleshooting issues in cHTTP or one of its dependencies.
pub fn version() -> String {
format!("chttp/{} {}", env!("CARGO_PKG_VERSION"), curl::Version::num())
}


/// An HTTP request.
pub type Request = http::Request<Body>;

/// An HTTP response.
pub type Response = http::Response<Body>;

lazy_static! {
static ref DEFAULT_CLIENT: Client = Client::new().unwrap();
}

/// Sends an HTTP GET request.
///
Expand Down Expand Up @@ -191,3 +197,7 @@ pub fn delete<U>(uri: U) -> Result<Response, Error> where http::Uri: http::HttpT
pub fn send<B: Into<Body>>(request: http::Request<B>) -> Result<Response, Error> {
DEFAULT_CLIENT.send(request.map(|body| body.into()))
}

lazy_static! {
static ref DEFAULT_CLIENT: Client = Client::new().unwrap();
}

0 comments on commit 2264095

Please sign in to comment.