Closed AlbanMinassian closed 6 years ago
app.get("/", vec![index]); not recognize !
app.get("/", vec![index]);
127.0.0.1:4321/plaintext
127.0.0.1:4321/
127.0.0.1:4321
How catch index page ? Ami44
most_basic.rs:
extern crate thruster; extern crate futures; use std::boxed::Box; use futures::future; use thruster::{App, BasicContext as Ctx, MiddlewareChain, MiddlewareReturnValue}; fn index(mut context: Ctx, _chain: &MiddlewareChain<Ctx>) -> MiddlewareReturnValue<Ctx> { context.body = "Hello, Index!".to_owned();; Box::new(future::ok(context)) } fn plaintext(mut context: Ctx, _chain: &MiddlewareChain<Ctx>) -> MiddlewareReturnValue<Ctx> { context.body = "Hello, Plaintext !".to_owned();; Box::new(future::ok(context)) } fn page404(mut context: Ctx, _chain: &MiddlewareChain<Ctx>) -> MiddlewareReturnValue<Ctx> { context.body = "Hello, 404 !".to_owned();; Box::new(future::ok(context)) } fn main() { println!("Starting server..."); let mut app = App::<Ctx>::new(); app.get("/", vec![index]); app.get("/plaintext", vec![plaintext]); app.get("/*", vec![page404]); App::start(app, "0.0.0.0", 4321); }
Hello, can you merge on master ?
Thank, it's work
app.get("/", vec![index]);
not recognize !127.0.0.1:4321/plaintext
: ok127.0.0.1:4321/
(or127.0.0.1:4321
) : ko, display always page 404How catch index page ? Ami44
most_basic.rs: