Compare commits

..

No commits in common. "930e33ba9311868d0ca02ccc96c4452206d2bc77" and "d368fc932a1ad68464a3e97a6827de4bb504d9b9" have entirely different histories.

4 changed files with 332 additions and 602 deletions

895
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,36 +1,36 @@
[package]
name = "huellas"
version = "0.3.0"
edition = "2024"
edition = "2021"
license = "AGPL-3.0"
[dependencies]
anyhow = "1.0.96"
axum = { version = "0.8.1", default-features = false, features = [
anyhow = "1.0.89"
axum = { version = "0.7.7", default-features = false, features = [
"tracing",
"tokio",
"http1",
"http2",
] }
axum-msgpack = "0.5.0"
axum-msgpack = "0.4.0"
dotenvy = "0.15.7"
futures = { version = "0.3.31", default-features = false }
serde = { version = "1.0.218", features = ["derive"] }
sqlx = { version = "0.8.3", default-features = false, features = [
serde = { version = "1.0.210", features = ["derive"] }
sqlx = { version = "0.8.2", default-features = false, features = [
"macros",
"migrate",
"runtime-tokio",
"sqlite",
"tls-rustls",
] }
tokio = { version = "1.43.0", default-features = false, features = [
tokio = { version = "1.40.0", default-features = false, features = [
"macros",
"rt-multi-thread",
"signal",
] }
tower-http = { version = "0.6.2", default-features = false, features = ["fs"] }
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", default-features = false, features = [
tower-http = { version = "0.6.1", default-features = false, features = ["fs"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
"env-filter",
"fmt",
"tracing",
@ -38,4 +38,4 @@ tracing-subscriber = { version = "0.3.19", default-features = false, features =
] }
[dev-dependencies]
axum-test = { version = "17.2.0", features = ["msgpack"] }
axum-test = { version = "16.2.0", features = ["msgpack"] }

View file

@ -1,10 +1,8 @@
use anyhow::{Context, Result};
use axum::Router;
use axum::serve::ListenerExt;
use sqlx::sqlite::SqlitePool;
use std::net::SocketAddr;
use tower_http::services::ServeDir;
use tracing::trace;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
mod place;
@ -39,14 +37,9 @@ async fn main() -> Result<()> {
let port = str::parse(&port).unwrap_or(3000);
let address = SocketAddr::from(([0, 0, 0, 0], port));
tracing::debug!("listening on {}", address);
let listener = tokio::net::TcpListener::bind(address)
.await?
.tap_io(|tcp_stream| {
if let Err(err) = tcp_stream.set_nodelay(true) {
trace!("failed to set TCP_NODELAY on incoming connection: {err:#}");
}
});
let listener = tokio::net::TcpListener::bind(address).await?;
axum::serve(listener, app.into_make_service())
.tcp_nodelay(true)
.with_graceful_shutdown(shutdown_signal())
.await?;

View file

@ -1,7 +1,7 @@
use axum::Router;
use axum::extract::{Path, State};
use axum::http::StatusCode;
use axum::routing::{delete, get};
use axum::Router;
use axum_msgpack::MsgPack;
use futures::TryStreamExt;
use sqlx::sqlite::SqlitePool;
@ -119,7 +119,7 @@ async fn delete_place(State(pool): State<SqlitePool>, Path(id): Path<i64>) -> Re
pub fn places_routes(pool: SqlitePool) -> Router {
Router::new()
.route("/", get(get_places).put(upsert_place))
.route("/{id}", delete(delete_place))
.route("/:id", delete(delete_place))
.with_state(pool)
}
@ -129,8 +129,8 @@ mod tests {
use crate::place::Place;
use anyhow::{Context, Result};
use axum::Router;
use axum::http::StatusCode;
use axum::Router;
use axum_test::TestServer;
use sqlx::sqlite::SqlitePool;