mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
add fakeshadow's actix-web in actix-http example
This commit is contained in:
parent
606a371ec3
commit
9587261c20
@ -84,6 +84,7 @@ zstd = { version = "0.9", optional = true }
|
|||||||
actix-server = "2.0.0-rc.1"
|
actix-server = "2.0.0-rc.1"
|
||||||
actix-http-test = { version = "3.0.0-beta.7", features = ["openssl"] }
|
actix-http-test = { version = "3.0.0-beta.7", features = ["openssl"] }
|
||||||
actix-tls = { version = "3.0.0-rc.1", features = ["openssl"] }
|
actix-tls = { version = "3.0.0-rc.1", features = ["openssl"] }
|
||||||
|
actix-web = "4.0.0-beta.13"
|
||||||
async-stream = "0.3"
|
async-stream = "0.3"
|
||||||
criterion = { version = "0.3", features = ["html_reports"] }
|
criterion = { version = "0.3", features = ["html_reports"] }
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
@ -95,7 +96,7 @@ serde_json = "1.0"
|
|||||||
static_assertions = "1"
|
static_assertions = "1"
|
||||||
tls-openssl = { package = "openssl", version = "0.10.9" }
|
tls-openssl = { package = "openssl", version = "0.10.9" }
|
||||||
tls-rustls = { package = "rustls", version = "0.20.0" }
|
tls-rustls = { package = "rustls", version = "0.20.0" }
|
||||||
tokio = { version = "1.2", features = ["net", "rt"] }
|
tokio = { version = "1.2", features = ["net", "rt", "macros"] }
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "ws"
|
name = "ws"
|
||||||
|
26
actix-http/examples/actix-web.rs
Normal file
26
actix-http/examples/actix-web.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
use actix_http::HttpService;
|
||||||
|
use actix_server::Server;
|
||||||
|
use actix_service::map_config;
|
||||||
|
use actix_web::{dev::AppConfig, get, App};
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
async fn index() -> &'static str {
|
||||||
|
"Hello, world. From Actix Web!"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main(flavor = "current_thread")]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
|
Server::build()
|
||||||
|
.bind("hello-world", "127.0.0.1:8080", || {
|
||||||
|
// construct actix-web app
|
||||||
|
let app = App::new().service(index);
|
||||||
|
|
||||||
|
HttpService::build()
|
||||||
|
// pass the app to service builder
|
||||||
|
// map_config is used to map App's configuration to ServiceBuilder
|
||||||
|
.finish(map_config(app, |_| AppConfig::default()))
|
||||||
|
.tcp()
|
||||||
|
})?
|
||||||
|
.run()
|
||||||
|
.await
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user