[−][src]Macro vial::run
The vial::run!
macro is the preferred way of starting your Vial
application after you've defined one or more routes using
vial::routes!
. run!
performs a bit of
necessary setup, then starts listening for client requests at
http://0.0.0.0:7667 by default.
There are four ways to use run!
:
-
vial::run!()
: No arguments. Starts listening at http://0.0.0.0:7667 and expects you to have calledvial::routes!
in the current module. -
vial::run!("localhost:9999")
: With your own address. -
vial::run!(blog, wiki)
: With modules that you've calledvial::routes!
from within. This will combine all the routes.For example:
mod wiki { vial::routes! { GET "/wiki" => |_| Response::from_file("wiki.html"); } } mod blog { vial::routes! { GET "/blog" => show_blog; // etc... } fn show_blog(req: vial::Request) -> String { // ... "blog".to_string() } } fn main() { vial::run!(wiki, blog).unwrap(); }
- Using a combination of the above:
fn main() { vial::run!("localhost:1111", blog, wiki).unwrap(); }