mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
add hello-world example
This commit is contained in:
parent
b49eadf7e5
commit
fb2c78d9fc
@ -37,6 +37,8 @@ script:
|
|||||||
|
|
||||||
- |
|
- |
|
||||||
if [[ "$TRAVIS_RUST_VERSION" == "1.20.0" ]]; then
|
if [[ "$TRAVIS_RUST_VERSION" == "1.20.0" ]]; then
|
||||||
|
cd examples/basics && cargo check && cd ../..
|
||||||
|
cd examples/hello-world && cargo check && cd ../..
|
||||||
cd examples/multipart && cargo check && cd ../..
|
cd examples/multipart && cargo check && cd ../..
|
||||||
cd examples/json && cargo check && cd ../..
|
cd examples/json && cargo check && cd ../..
|
||||||
cd examples/template_tera && cargo check && cd ../..
|
cd examples/template_tera && cargo check && cd ../..
|
||||||
|
@ -103,9 +103,10 @@ opt-level = 3
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"./",
|
"./",
|
||||||
"examples/basic",
|
"examples/basics",
|
||||||
"examples/diesel",
|
"examples/diesel",
|
||||||
"examples/json",
|
"examples/json",
|
||||||
|
"examples/hello-world",
|
||||||
"examples/multipart",
|
"examples/multipart",
|
||||||
"examples/signals",
|
"examples/signals",
|
||||||
"examples/state",
|
"examples/state",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "basic"
|
name = "basics"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
workspace = "../.."
|
workspace = "../.."
|
10
examples/hello-world/Cargo.toml
Normal file
10
examples/hello-world/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "hello-world"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
|
workspace = "../.."
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
env_logger = "0.4"
|
||||||
|
actix = "^0.3.5"
|
||||||
|
actix-web = { path = "../../" }
|
28
examples/hello-world/src/main.rs
Normal file
28
examples/hello-world/src/main.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
extern crate actix;
|
||||||
|
extern crate actix_web;
|
||||||
|
extern crate env_logger;
|
||||||
|
|
||||||
|
use actix_web::*;
|
||||||
|
|
||||||
|
|
||||||
|
fn index(_req: HttpRequest) -> &'static str {
|
||||||
|
"Hello world!"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
::std::env::set_var("RUST_LOG", "actix_web=info");
|
||||||
|
let _ = env_logger::init();
|
||||||
|
let sys = actix::System::new("ws-example");
|
||||||
|
|
||||||
|
let _addr = HttpServer::new(
|
||||||
|
|| Application::new()
|
||||||
|
// enable logger
|
||||||
|
.middleware(middleware::Logger::default())
|
||||||
|
.resource("/index.html", |r| r.f(|_| "Hello world!"))
|
||||||
|
.resource("/", |r| r.f(index)))
|
||||||
|
.bind("127.0.0.1:8080").unwrap()
|
||||||
|
.start();
|
||||||
|
|
||||||
|
println!("Started http server: 127.0.0.1:8080");
|
||||||
|
let _ = sys.run();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user