summaryrefslogtreecommitdiff
path: root/actix
diff options
context:
space:
mode:
Diffstat (limited to 'actix')
-rw-r--r--actix/Cargo.lock63
-rw-r--r--actix/Cargo.toml1
-rw-r--r--actix/Makefile1
-rw-r--r--actix/src/main.rs28
4 files changed, 91 insertions, 2 deletions
diff --git a/actix/Cargo.lock b/actix/Cargo.lock
index b28575c..52cd0db 100644
--- a/actix/Cargo.lock
+++ b/actix/Cargo.lock
@@ -5,6 +5,7 @@ name = "actix"
version = "0.1.0"
dependencies = [
"actix-web",
+ "clap",
]
[[package]]
@@ -293,6 +294,15 @@ dependencies = [
]
[[package]]
+name = "ansi_term"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
+dependencies = [
+ "winapi 0.3.9",
+]
+
+[[package]]
name = "async-trait"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -304,6 +314,17 @@ dependencies = [
]
[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi 0.3.9",
+]
+
+[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -446,6 +467,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
+name = "clap"
+version = "2.33.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
+dependencies = [
+ "ansi_term",
+ "atty",
+ "bitflags",
+ "strsim",
+ "textwrap",
+ "unicode-width",
+ "vec_map",
+]
+
+[[package]]
name = "const_fn"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1405,6 +1441,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
[[package]]
+name = "strsim"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
+
+[[package]]
name = "syn"
version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1416,6 +1458,15 @@ dependencies = [
]
[[package]]
+name = "textwrap"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
name = "thiserror"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1642,6 +1693,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
+name = "unicode-width"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
+
+[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1660,6 +1717,12 @@ dependencies = [
]
[[package]]
+name = "vec_map"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
+
+[[package]]
name = "version_check"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/actix/Cargo.toml b/actix/Cargo.toml
index bd2bc84..abbda7b 100644
--- a/actix/Cargo.toml
+++ b/actix/Cargo.toml
@@ -8,3 +8,4 @@ edition = "2018"
[dependencies]
actix-web = "3"
+clap = "2.33.3"
diff --git a/actix/Makefile b/actix/Makefile
index b815ebe..0222e71 100644
--- a/actix/Makefile
+++ b/actix/Makefile
@@ -2,7 +2,6 @@
debug:
cargo build
- ./target/debug/actix
release:
cargo build --release
diff --git a/actix/src/main.rs b/actix/src/main.rs
index 4f03d08..f11798f 100644
--- a/actix/src/main.rs
+++ b/actix/src/main.rs
@@ -1,6 +1,10 @@
+// vim: tabstop=4 shiftwidth=4 expandtab
+
+extern crate clap;
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
+
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
@@ -17,13 +21,35 @@ async fn manual_hello() -> impl Responder {
#[actix_web::main]
async fn main() -> std::io::Result<()> {
+
+ let arg_matches = clap::App::new("Actix Web Server")
+ .about("Executable to run the web-template Web Server")
+ .arg(clap::Arg::with_name("address")
+ .help("The address to which the server binds")
+ .long("address")
+ .short("a")
+ .takes_value(true)
+ .default_value("127.0.0.1"))
+ .arg(clap::Arg::with_name("port")
+ .help("The port to which the server binds")
+ .long("port")
+ .short("p")
+ .takes_value(true)
+ .default_value("8080"))
+ .get_matches();
+
+ let address = arg_matches.value_of("address").unwrap();
+ let port = arg_matches.value_of("port").unwrap();
+
+ println!("Binding to {}:{}", address, port);
+
HttpServer::new(|| {
App::new()
.service(hello)
.service(echo)
.route("/hey", web::get().to(manual_hello))
})
- .bind("127.0.0.1:8080")?
+ .bind(format!("{}:{}", address, port))?
.run()
.await
}