From b53642da26f9bc6366d6174bbbc8ba89dc314f3b Mon Sep 17 00:00:00 2001 From: Felipe Noronha Date: Mon, 11 Mar 2019 14:12:28 -0300 Subject: [PATCH] use edition 2018. bump dependencies. (#5) --- Cargo.toml | 9 +++++---- README.md | 15 ++++++++------- src/lib.rs | 20 ++++++++------------ 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb0ccb3..b9c4485 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hyper-reverse-proxy" -version = "0.3.0" +version = "0.4.0" authors = ["Brendan Zabarauskas ", "Felipe Noronha "] license = "Apache-2.0" description = "A simple reverse proxy, to be used with Hyper and Tokio." @@ -10,6 +10,7 @@ repository = "https://github.com/felipenoris/hyper-reverse-proxy" keywords = ["http", "hyper"] categories = ["network-programming", "web-programming"] readme = "README.md" +edition = "2018" include = [ "Cargo.toml", @@ -18,7 +19,7 @@ include = [ ] [dependencies] -hyper = "0.12.24" +hyper = "0.12" futures = "0.1" -lazy_static = "1.2" -unicase = "2.2" +lazy_static = "1.3" +unicase = "2.3" diff --git a/README.md b/README.md index afef0c3..8cd11a7 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Add these dependencies to your `Cargo.toml` file. ```toml [dependencies] -hyper-reverse-proxy = "0.3.0" -hyper = "0.12.24" +hyper-reverse-proxy = "0.4" +hyper = "0.12" futures = "0.1" ``` @@ -39,10 +39,6 @@ and will proxy these calls: * All other URLs will be handled by `debug_request` function, that will display request information. ```rust,no_run -extern crate hyper; -extern crate hyper_reverse_proxy; -extern crate futures; - use hyper::server::conn::AddrStream; use hyper::{Body, Request, Response, Server}; use hyper::service::{service_fn, make_service_fn}; @@ -66,11 +62,16 @@ fn main() { let remote_addr = socket.remote_addr(); service_fn(move |req: Request| { // returns BoxFut - // Auth if req.uri().path().starts_with("/target/first") { + + // will forward requests to port 13901 return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13901", req) + } else if req.uri().path().starts_with("/target/second") { + + // will forward requests to port 13902 return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13902", req) + } else { debug_request(req) } diff --git a/src/lib.rs b/src/lib.rs index 2d34938..ef34fe5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,8 +17,8 @@ //! //! ```toml //! [dependencies] -//! hyper-reverse-proxy = "0.3.0" -//! hyper = "0.12.24" +//! hyper-reverse-proxy = "0.4" +//! hyper = "0.12" //! futures = "0.1" //! ``` //! @@ -32,10 +32,6 @@ //! * All other URLs will be handled by `debug_request` function, that will display request information. //! //! ```rust,no_run -//! extern crate hyper; -//! extern crate hyper_reverse_proxy; -//! extern crate futures; -//! //! use hyper::server::conn::AddrStream; //! use hyper::{Body, Request, Response, Server}; //! use hyper::service::{service_fn, make_service_fn}; @@ -59,11 +55,16 @@ //! let remote_addr = socket.remote_addr(); //! service_fn(move |req: Request| { // returns BoxFut //! -//! // Auth //! if req.uri().path().starts_with("/target/first") { +//! +//! // will forward requests to port 13901 //! return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13901", req) +//! //! } else if req.uri().path().starts_with("/target/second") { +//! +//! // will forward requests to port 13902 //! return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13902", req) +//! //! } else { //! debug_request(req) //! } @@ -82,11 +83,6 @@ //! ``` //! -extern crate hyper; -extern crate futures; -extern crate lazy_static; -extern crate unicase; - use hyper::Body; use std::net::IpAddr; use std::str::FromStr;