use edition 2018. bump dependencies. (#5)
This commit is contained in:
parent
48ed13e6ae
commit
b53642da26
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hyper-reverse-proxy"
|
name = "hyper-reverse-proxy"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>", "Felipe Noronha <felipenoris@gmail.com>"]
|
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>", "Felipe Noronha <felipenoris@gmail.com>"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
description = "A simple reverse proxy, to be used with Hyper and Tokio."
|
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"]
|
keywords = ["http", "hyper"]
|
||||||
categories = ["network-programming", "web-programming"]
|
categories = ["network-programming", "web-programming"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
include = [
|
include = [
|
||||||
"Cargo.toml",
|
"Cargo.toml",
|
||||||
@ -18,7 +19,7 @@ include = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hyper = "0.12.24"
|
hyper = "0.12"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
lazy_static = "1.2"
|
lazy_static = "1.3"
|
||||||
unicase = "2.2"
|
unicase = "2.3"
|
||||||
|
15
README.md
15
README.md
@ -24,8 +24,8 @@ Add these dependencies to your `Cargo.toml` file.
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hyper-reverse-proxy = "0.3.0"
|
hyper-reverse-proxy = "0.4"
|
||||||
hyper = "0.12.24"
|
hyper = "0.12"
|
||||||
futures = "0.1"
|
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.
|
* All other URLs will be handled by `debug_request` function, that will display request information.
|
||||||
|
|
||||||
```rust,no_run
|
```rust,no_run
|
||||||
extern crate hyper;
|
|
||||||
extern crate hyper_reverse_proxy;
|
|
||||||
extern crate futures;
|
|
||||||
|
|
||||||
use hyper::server::conn::AddrStream;
|
use hyper::server::conn::AddrStream;
|
||||||
use hyper::{Body, Request, Response, Server};
|
use hyper::{Body, Request, Response, Server};
|
||||||
use hyper::service::{service_fn, make_service_fn};
|
use hyper::service::{service_fn, make_service_fn};
|
||||||
@ -66,11 +62,16 @@ fn main() {
|
|||||||
let remote_addr = socket.remote_addr();
|
let remote_addr = socket.remote_addr();
|
||||||
service_fn(move |req: Request<Body>| { // returns BoxFut
|
service_fn(move |req: Request<Body>| { // returns BoxFut
|
||||||
|
|
||||||
// Auth
|
|
||||||
if req.uri().path().starts_with("/target/first") {
|
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)
|
return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13901", req)
|
||||||
|
|
||||||
} else if req.uri().path().starts_with("/target/second") {
|
} 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)
|
return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13902", req)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
debug_request(req)
|
debug_request(req)
|
||||||
}
|
}
|
||||||
|
20
src/lib.rs
20
src/lib.rs
@ -17,8 +17,8 @@
|
|||||||
//!
|
//!
|
||||||
//! ```toml
|
//! ```toml
|
||||||
//! [dependencies]
|
//! [dependencies]
|
||||||
//! hyper-reverse-proxy = "0.3.0"
|
//! hyper-reverse-proxy = "0.4"
|
||||||
//! hyper = "0.12.24"
|
//! hyper = "0.12"
|
||||||
//! futures = "0.1"
|
//! futures = "0.1"
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
@ -32,10 +32,6 @@
|
|||||||
//! * All other URLs will be handled by `debug_request` function, that will display request information.
|
//! * All other URLs will be handled by `debug_request` function, that will display request information.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! extern crate hyper;
|
|
||||||
//! extern crate hyper_reverse_proxy;
|
|
||||||
//! extern crate futures;
|
|
||||||
//!
|
|
||||||
//! use hyper::server::conn::AddrStream;
|
//! use hyper::server::conn::AddrStream;
|
||||||
//! use hyper::{Body, Request, Response, Server};
|
//! use hyper::{Body, Request, Response, Server};
|
||||||
//! use hyper::service::{service_fn, make_service_fn};
|
//! use hyper::service::{service_fn, make_service_fn};
|
||||||
@ -59,11 +55,16 @@
|
|||||||
//! let remote_addr = socket.remote_addr();
|
//! let remote_addr = socket.remote_addr();
|
||||||
//! service_fn(move |req: Request<Body>| { // returns BoxFut
|
//! service_fn(move |req: Request<Body>| { // returns BoxFut
|
||||||
//!
|
//!
|
||||||
//! // Auth
|
|
||||||
//! if req.uri().path().starts_with("/target/first") {
|
//! 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)
|
//! return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13901", req)
|
||||||
|
//!
|
||||||
//! } else if req.uri().path().starts_with("/target/second") {
|
//! } 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)
|
//! return hyper_reverse_proxy::call(remote_addr.ip(), "http://127.0.0.1:13902", req)
|
||||||
|
//!
|
||||||
//! } else {
|
//! } else {
|
||||||
//! debug_request(req)
|
//! debug_request(req)
|
||||||
//! }
|
//! }
|
||||||
@ -82,11 +83,6 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
||||||
extern crate hyper;
|
|
||||||
extern crate futures;
|
|
||||||
extern crate lazy_static;
|
|
||||||
extern crate unicase;
|
|
||||||
|
|
||||||
use hyper::Body;
|
use hyper::Body;
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
Loading…
Reference in New Issue
Block a user