aboutsummaryrefslogtreecommitdiffstats
path: root/crates/server
diff options
context:
space:
mode:
Diffstat (limited to 'crates/server')
-rw-r--r--crates/server/src/handlers/mod.rs8
-rw-r--r--crates/server/src/handlers/v0/mod.rs2
-rw-r--r--crates/server/src/handlers/v0/record.rs8
-rw-r--r--crates/server/src/metrics.rs4
-rw-r--r--crates/server/src/router.rs6
-rw-r--r--crates/server/src/settings.rs2
6 files changed, 15 insertions, 15 deletions
diff --git a/crates/server/src/handlers/mod.rs b/crates/server/src/handlers/mod.rs
index e24bad14..1ac5a0c4 100644
--- a/crates/server/src/handlers/mod.rs
+++ b/crates/server/src/handlers/mod.rs
@@ -3,11 +3,11 @@ use axum::{Json, extract::State, http, response::IntoResponse};
use crate::router::AppState;
-pub mod v0;
+pub(crate) mod v0;
const VERSION: &str = env!("CARGO_PKG_VERSION");
-pub async fn index(state: State<AppState>) -> Json<IndexResponse> {
+pub(crate) async fn index(state: State<AppState>) -> Json<IndexResponse> {
let homage = r#""Through the fathomless deeps of space swims the star turtle Great A'Tuin, bearing on its back the four giant elephants who carry on their shoulders the mass of the Discworld." -- Sir Terry Pratchett"#;
let version = state
@@ -28,12 +28,12 @@ impl IntoResponse for ErrorResponseStatus<'_> {
}
}
-pub struct ErrorResponseStatus<'a> {
+pub(crate) struct ErrorResponseStatus<'a> {
pub error: ErrorResponse<'a>,
pub status: http::StatusCode,
}
-pub trait RespExt<'a> {
+pub(crate) trait RespExt<'a> {
fn with_status(self, status: http::StatusCode) -> ErrorResponseStatus<'a>;
fn reply(reason: &'a str) -> Self;
}
diff --git a/crates/server/src/handlers/v0/mod.rs b/crates/server/src/handlers/v0/mod.rs
index 2066636c..78fb47b8 100644
--- a/crates/server/src/handlers/v0/mod.rs
+++ b/crates/server/src/handlers/v0/mod.rs
@@ -1 +1 @@
-pub mod record;
+pub(crate) mod record;
diff --git a/crates/server/src/handlers/v0/record.rs b/crates/server/src/handlers/v0/record.rs
index f7758c1a..61fa2946 100644
--- a/crates/server/src/handlers/v0/record.rs
+++ b/crates/server/src/handlers/v0/record.rs
@@ -11,7 +11,7 @@ use crate::{
use turtle_common::record::{EncryptedData, HostId, Record, RecordIdx, RecordStatus};
#[instrument(skip_all, fields(user.id = user.id.to_string()))]
-pub async fn post(
+pub(crate) async fn post(
UserAuth(user): UserAuth,
state: State<AppState>,
Json(records): Json<Vec<Record<EncryptedData>>>,
@@ -50,7 +50,7 @@ pub async fn post(
}
#[instrument(skip_all, fields(user.id = user.id.to_string()))]
-pub async fn index(
+pub(crate) async fn index(
UserAuth(user): UserAuth,
state: State<AppState>,
) -> Result<Json<RecordStatus>, ErrorResponseStatus<'static>> {
@@ -75,7 +75,7 @@ pub async fn index(
}
#[derive(Deserialize)]
-pub struct NextParams {
+pub(crate) struct NextParams {
host: HostId,
tag: String,
start: Option<RecordIdx>,
@@ -83,7 +83,7 @@ pub struct NextParams {
}
#[instrument(skip_all, fields(user.id = user.id.to_string()))]
-pub async fn next(
+pub(crate) async fn next(
params: Query<NextParams>,
UserAuth(user): UserAuth,
state: State<AppState>,
diff --git a/crates/server/src/metrics.rs b/crates/server/src/metrics.rs
index 987af807..6380bef1 100644
--- a/crates/server/src/metrics.rs
+++ b/crates/server/src/metrics.rs
@@ -7,7 +7,7 @@ use axum::{
};
use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle};
-pub fn setup_metrics_recorder() -> PrometheusHandle {
+pub(crate) fn setup_metrics_recorder() -> PrometheusHandle {
const EXPONENTIAL_SECONDS: &[f64] = &[
0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0,
];
@@ -25,7 +25,7 @@ pub fn setup_metrics_recorder() -> PrometheusHandle {
/// Middleware to record some common HTTP metrics
/// Generic over B to allow for arbitrary body types (eg Vec<u8>, Streams, a deserialized thing, etc)
/// Someday tower-http might provide a metrics middleware: <https://github.com/tower-rs/tower-http/issues/57>
-pub async fn track_metrics(req: Request, next: Next) -> impl IntoResponse {
+pub(crate) async fn track_metrics(req: Request, next: Next) -> impl IntoResponse {
let start = Instant::now();
let path = req.extensions().get::<MatchedPath>().map_or_else(
diff --git a/crates/server/src/router.rs b/crates/server/src/router.rs
index b0b98ecc..ce12f5b6 100644
--- a/crates/server/src/router.rs
+++ b/crates/server/src/router.rs
@@ -21,7 +21,7 @@ use crate::{
settings::Settings,
};
-pub struct UserAuth(pub User);
+pub(crate) struct UserAuth(pub User);
impl FromRequestParts<AppState> for UserAuth {
type Rejection = ErrorResponseStatus<'static>;
@@ -65,12 +65,12 @@ async fn semver(request: Request, next: Next) -> Response {
}
#[derive(Clone)]
-pub struct AppState {
+pub(crate) struct AppState {
pub database: ServerPostgres,
pub settings: Settings,
}
-pub fn router(database: ServerPostgres, settings: Settings) -> Router {
+pub(crate) fn router(database: ServerPostgres, settings: Settings) -> Router {
let routes = Router::new()
.route("/", get(handlers::index))
.route("/api/v0/{user_id}/record", post(handlers::v0::record::post))
diff --git a/crates/server/src/settings.rs b/crates/server/src/settings.rs
index e6626b15..256aa661 100644
--- a/crates/server/src/settings.rs
+++ b/crates/server/src/settings.rs
@@ -67,7 +67,7 @@ impl Settings {
.separator("__"),
);
- if let Ok(mut config_file) = std::env::var("TURTLE_SERVER_CONFIG").map(PathBuf::from) {
+ if let Ok(config_file) = std::env::var("TURTLE_SERVER_CONFIG").map(PathBuf::from) {
config_builder = if config_file.exists() {
config_builder.add_source(ConfigFile::new(
config_file.to_str().unwrap(),