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"
|
serde_json = "1.0.115"
|
||||||
tokio = { version = "1.37.0", features = ["full"] }
|
tokio = { version = "1.37.0", features = ["full"] }
|
||||||
tower = "0.4.13"
|
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 = "0.1.40"
|
||||||
tracing-subscriber = "0.3.18"
|
tracing-subscriber = "0.3.18"
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -1,24 +1,22 @@
|
||||||
mod dem;
|
mod dem;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, State},
|
extract::{Path, State}, http::Request, routing::get, Router
|
||||||
routing::get,
|
|
||||||
Router,
|
|
||||||
};
|
};
|
||||||
use axum_macros::debug_handler;
|
use axum_macros::debug_handler;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use tower_http::services::ServeDir;
|
use tower_http::{services::ServeDir, trace::{self, DefaultMakeSpan}};
|
||||||
|
|
||||||
use dem::DatasetRepository;
|
use dem::DatasetRepository;
|
||||||
|
|
||||||
use tracing::info;
|
use tracing::{info, Level, Span};
|
||||||
|
use tower_http::trace::TraceLayer;
|
||||||
|
|
||||||
|
|
||||||
const DEFAULT_DATA_DIR: &str = "/data";
|
const DEFAULT_DATA_DIR: &str = "/data";
|
||||||
const DEFAULT_PORT: &str = "3000";
|
const DEFAULT_PORT: &str = "3000";
|
||||||
|
|
||||||
//#[tokio::main(flavor = "current_thread")]
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// initialize tracing
|
// initialize tracing
|
||||||
|
@ -30,11 +28,15 @@ async fn main() {
|
||||||
|
|
||||||
let serve_dir = ServeDir::new("assets");
|
let serve_dir = ServeDir::new("assets");
|
||||||
|
|
||||||
// build our application with a route
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/elevation/:lat/:lon", get(get_elevation))
|
.route("/elevation/:lat/:lon", get(get_elevation))
|
||||||
.nest_service("/", serve_dir)
|
.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);
|
let host = format!("[::]:{}", config.port);
|
||||||
info!("Will start server on {host}");
|
info!("Will start server on {host}");
|
||||||
|
|
Loading…
Reference in a new issue