Compare commits
No commits in common. "930e33ba9311868d0ca02ccc96c4452206d2bc77" and "d368fc932a1ad68464a3e97a6827de4bb504d9b9" have entirely different histories.
930e33ba93
...
d368fc932a
4 changed files with 332 additions and 602 deletions
895
Cargo.lock
generated
895
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
22
Cargo.toml
22
Cargo.toml
|
|
@ -1,36 +1,36 @@
|
||||||
[package]
|
[package]
|
||||||
name = "huellas"
|
name = "huellas"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
edition = "2024"
|
edition = "2021"
|
||||||
license = "AGPL-3.0"
|
license = "AGPL-3.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.96"
|
anyhow = "1.0.89"
|
||||||
axum = { version = "0.8.1", default-features = false, features = [
|
axum = { version = "0.7.7", default-features = false, features = [
|
||||||
"tracing",
|
"tracing",
|
||||||
"tokio",
|
"tokio",
|
||||||
"http1",
|
"http1",
|
||||||
"http2",
|
"http2",
|
||||||
] }
|
] }
|
||||||
axum-msgpack = "0.5.0"
|
axum-msgpack = "0.4.0"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
futures = { version = "0.3.31", default-features = false }
|
futures = { version = "0.3.31", default-features = false }
|
||||||
serde = { version = "1.0.218", features = ["derive"] }
|
serde = { version = "1.0.210", features = ["derive"] }
|
||||||
sqlx = { version = "0.8.3", default-features = false, features = [
|
sqlx = { version = "0.8.2", default-features = false, features = [
|
||||||
"macros",
|
"macros",
|
||||||
"migrate",
|
"migrate",
|
||||||
"runtime-tokio",
|
"runtime-tokio",
|
||||||
"sqlite",
|
"sqlite",
|
||||||
"tls-rustls",
|
"tls-rustls",
|
||||||
] }
|
] }
|
||||||
tokio = { version = "1.43.0", default-features = false, features = [
|
tokio = { version = "1.40.0", default-features = false, features = [
|
||||||
"macros",
|
"macros",
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
"signal",
|
"signal",
|
||||||
] }
|
] }
|
||||||
tower-http = { version = "0.6.2", default-features = false, features = ["fs"] }
|
tower-http = { version = "0.6.1", default-features = false, features = ["fs"] }
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.40"
|
||||||
tracing-subscriber = { version = "0.3.19", default-features = false, features = [
|
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
|
||||||
"env-filter",
|
"env-filter",
|
||||||
"fmt",
|
"fmt",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
@ -38,4 +38,4 @@ tracing-subscriber = { version = "0.3.19", default-features = false, features =
|
||||||
] }
|
] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
axum-test = { version = "17.2.0", features = ["msgpack"] }
|
axum-test = { version = "16.2.0", features = ["msgpack"] }
|
||||||
|
|
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -1,10 +1,8 @@
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use axum::Router;
|
use axum::Router;
|
||||||
use axum::serve::ListenerExt;
|
|
||||||
use sqlx::sqlite::SqlitePool;
|
use sqlx::sqlite::SqlitePool;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use tower_http::services::ServeDir;
|
use tower_http::services::ServeDir;
|
||||||
use tracing::trace;
|
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
mod place;
|
mod place;
|
||||||
|
|
@ -39,14 +37,9 @@ async fn main() -> Result<()> {
|
||||||
let port = str::parse(&port).unwrap_or(3000);
|
let port = str::parse(&port).unwrap_or(3000);
|
||||||
let address = SocketAddr::from(([0, 0, 0, 0], port));
|
let address = SocketAddr::from(([0, 0, 0, 0], port));
|
||||||
tracing::debug!("listening on {}", address);
|
tracing::debug!("listening on {}", address);
|
||||||
let listener = tokio::net::TcpListener::bind(address)
|
let listener = tokio::net::TcpListener::bind(address).await?;
|
||||||
.await?
|
|
||||||
.tap_io(|tcp_stream| {
|
|
||||||
if let Err(err) = tcp_stream.set_nodelay(true) {
|
|
||||||
trace!("failed to set TCP_NODELAY on incoming connection: {err:#}");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
axum::serve(listener, app.into_make_service())
|
axum::serve(listener, app.into_make_service())
|
||||||
|
.tcp_nodelay(true)
|
||||||
.with_graceful_shutdown(shutdown_signal())
|
.with_graceful_shutdown(shutdown_signal())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use axum::Router;
|
|
||||||
use axum::extract::{Path, State};
|
use axum::extract::{Path, State};
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum::routing::{delete, get};
|
use axum::routing::{delete, get};
|
||||||
|
use axum::Router;
|
||||||
use axum_msgpack::MsgPack;
|
use axum_msgpack::MsgPack;
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use sqlx::sqlite::SqlitePool;
|
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 {
|
pub fn places_routes(pool: SqlitePool) -> Router {
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/", get(get_places).put(upsert_place))
|
.route("/", get(get_places).put(upsert_place))
|
||||||
.route("/{id}", delete(delete_place))
|
.route("/:id", delete(delete_place))
|
||||||
.with_state(pool)
|
.with_state(pool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,8 +129,8 @@ mod tests {
|
||||||
use crate::place::Place;
|
use crate::place::Place;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use axum::Router;
|
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
|
use axum::Router;
|
||||||
use axum_test::TestServer;
|
use axum_test::TestServer;
|
||||||
use sqlx::sqlite::SqlitePool;
|
use sqlx::sqlite::SqlitePool;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue