2020-10-31 19:53:03 +00:00
|
|
|
use anyhow::*;
|
2020-11-14 02:56:50 +00:00
|
|
|
use log::LevelFilter;
|
2020-10-31 19:53:03 +00:00
|
|
|
use northstar::{Server, Request, Response, GEMINI_PORT};
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
2020-11-14 02:56:50 +00:00
|
|
|
env_logger::builder()
|
|
|
|
.filter_module("northstar", LevelFilter::Debug)
|
|
|
|
.init();
|
|
|
|
|
2020-10-31 19:53:03 +00:00
|
|
|
Server::bind(("localhost", GEMINI_PORT))
|
2020-11-20 03:33:44 +00:00
|
|
|
.add_route("/", handle_request)
|
|
|
|
.serve()
|
2020-10-31 19:53:03 +00:00
|
|
|
.await
|
|
|
|
}
|
|
|
|
|
2020-11-20 04:39:07 +00:00
|
|
|
async fn handle_request(request: Request) -> Result<Response> {
|
|
|
|
let path = request.path_segments();
|
|
|
|
let response = northstar::util::serve_dir("public", &path).await?;
|
2020-10-31 19:53:03 +00:00
|
|
|
|
2020-11-20 04:39:07 +00:00
|
|
|
Ok(response)
|
2020-10-31 19:53:03 +00:00
|
|
|
}
|