initial commit
This commit is contained in:
commit
40f551209b
7 changed files with 974 additions and 0 deletions
44
main.rs
Normal file
44
main.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use xitca_web::{
|
||||
App,
|
||||
handler::handler_service,
|
||||
middleware::Logger,
|
||||
middleware::{compress::Compress, decompress::Decompress},
|
||||
route::get,
|
||||
};
|
||||
|
||||
async fn root() -> &'static str {
|
||||
"aslkdm"
|
||||
}
|
||||
|
||||
use argh::FromArgs;
|
||||
|
||||
#[derive(FromArgs)]
|
||||
/// Official OSAKA server implementation
|
||||
struct CLIArgs {
|
||||
/// server IP (default: 0.0.0.0)
|
||||
#[argh(option)]
|
||||
host: Option<String>,
|
||||
|
||||
/// server port (default: 80)
|
||||
#[argh(option)]
|
||||
port: Option<u16>,
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let cli_args: CLIArgs = argh::from_env();
|
||||
let addr = format!(
|
||||
"{}:{}",
|
||||
cli_args.host.unwrap_or("0.0.0.0".to_string()),
|
||||
cli_args.port.unwrap_or(80)
|
||||
);
|
||||
|
||||
App::new()
|
||||
.at("/", get(handler_service(root)))
|
||||
.enclosed(Compress)
|
||||
.enclosed(Decompress)
|
||||
.enclosed(Logger::new())
|
||||
.serve()
|
||||
.bind(addr)?
|
||||
.run()
|
||||
.wait()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue