add some dumb logs
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
parent
f34e8ba309
commit
e4657c87e6
2 changed files with 12 additions and 10 deletions
|
@ -15,6 +15,6 @@ serde = { version = "1.0.197", features = ["derive"] }
|
|||
serde_json = "1.0.115"
|
||||
tokio = { version = "1.37.0", features = ["full"] }
|
||||
tower = "0.4.13"
|
||||
tower-http = { version = "0.5.2", features = ["fs"]}
|
||||
tower-http = { version = "0.5.2", features = ["fs", "trace"]}
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = "0.3.18"
|
||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -1,24 +1,22 @@
|
|||
mod dem;
|
||||
|
||||
use axum::{
|
||||
extract::{Path, State},
|
||||
routing::get,
|
||||
Router,
|
||||
extract::{Path, State}, http::Request, routing::get, Router
|
||||
};
|
||||
use axum_macros::debug_handler;
|
||||
use std::env;
|
||||
|
||||
use tower_http::services::ServeDir;
|
||||
use tower_http::{services::ServeDir, trace::{self, DefaultMakeSpan}};
|
||||
|
||||
use dem::DatasetRepository;
|
||||
|
||||
use tracing::info;
|
||||
use tracing::{info, Level, Span};
|
||||
use tower_http::trace::TraceLayer;
|
||||
|
||||
|
||||
const DEFAULT_DATA_DIR: &str = "/data";
|
||||
const DEFAULT_PORT: &str = "3000";
|
||||
|
||||
//#[tokio::main(flavor = "current_thread")]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// initialize tracing
|
||||
|
@ -30,11 +28,15 @@ async fn main() {
|
|||
|
||||
let serve_dir = ServeDir::new("assets");
|
||||
|
||||
// build our application with a route
|
||||
let app = Router::new()
|
||||
.route("/elevation/:lat/:lon", get(get_elevation))
|
||||
.nest_service("/", serve_dir)
|
||||
.with_state(cache);
|
||||
.with_state(cache)
|
||||
.layer(
|
||||
TraceLayer::new_for_http()
|
||||
.make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
|
||||
.on_response(trace::DefaultOnResponse::new().level(Level::INFO)),
|
||||
);
|
||||
|
||||
let host = format!("[::]:{}", config.port);
|
||||
info!("Will start server on {host}");
|
||||
|
@ -61,4 +63,4 @@ fn load_config() -> Result<Config, env::VarError> {
|
|||
struct Config {
|
||||
basedir: String,
|
||||
port: String,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue