kill some fully qualified paths
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
use axum::{http::StatusCode, response::IntoResponse};
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error("{0}")]
|
||||
pub struct DatabaseError(#[from] sqlx::Error);
|
||||
impl IntoResponse for DatabaseError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
fn into_response(self) -> Response {
|
||||
log::error!("[DB ERROR] {}", self);
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, "Internal server error.").into_response()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::error::Error;
|
||||
|
||||
use axum::Router;
|
||||
use dotenvy::var;
|
||||
use log::LevelFilter;
|
||||
use sqlx::PgPool;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
@@ -35,8 +36,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
return Err(e.into());
|
||||
}
|
||||
env_logger::builder()
|
||||
.filter_level(log::LevelFilter::Info)
|
||||
.filter_module("sqlx", log::LevelFilter::Warn)
|
||||
.filter_level(LevelFilter::Info)
|
||||
.filter_module("sqlx", LevelFilter::Warn)
|
||||
.parse_default_env()
|
||||
.format(config::envlogger_write_format)
|
||||
.init();
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use axum::{http::StatusCode, response::IntoResponse};
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use serde::Serialize;
|
||||
use sqlx::{PgConnection, Row};
|
||||
@@ -250,7 +253,7 @@ impl From<sqlx::Error> for QuoteError {
|
||||
}
|
||||
|
||||
impl IntoResponse for QuoteError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
fn into_response(self) -> Response {
|
||||
match self {
|
||||
Self::DatabaseError(e) => e.into_response(),
|
||||
Self::NoQuoteWithId(_) => (StatusCode::BAD_REQUEST, self.to_string()).into_response(),
|
||||
|
||||
@@ -7,6 +7,7 @@ use rand::seq::IndexedRandom;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
config::REFERENCE_SPLASHES,
|
||||
error::CompositeError,
|
||||
users::{User, auth::UserAuthenticate},
|
||||
@@ -19,7 +20,7 @@ pub struct LoginMsg {
|
||||
}
|
||||
|
||||
pub async fn page(
|
||||
State(state): State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
Query(q): Query<LoginMsg>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
@@ -2,15 +2,13 @@ use axum::extract::{Request, State};
|
||||
use maud::{Markup, html};
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
users::{User, auth::UserAuthenticate},
|
||||
web::{components::nav::nav, pages::base},
|
||||
};
|
||||
|
||||
pub async fn page(
|
||||
State(state): State<crate::MnemoState>,
|
||||
req: Request,
|
||||
) -> Result<Markup, CompositeError> {
|
||||
pub async fn page(State(state): State<MnemoState>, req: Request) -> Result<Markup, CompositeError> {
|
||||
let mut conn = state.pool.acquire().await?;
|
||||
let u = User::authenticate(&mut *conn, req.headers())
|
||||
.await
|
||||
|
||||
@@ -9,6 +9,7 @@ use maud::{PreEscaped, html};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
persons::Person,
|
||||
@@ -22,7 +23,7 @@ use crate::{
|
||||
pub mod profile;
|
||||
|
||||
pub async fn page(
|
||||
State(state): State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let mut conn = state.pool.acquire().await?;
|
||||
@@ -106,7 +107,7 @@ pub struct PersonNameForm {
|
||||
primary_name: String,
|
||||
}
|
||||
pub async fn create(
|
||||
State(state): State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
headers: HeaderMap,
|
||||
Form(form): Form<PersonNameForm>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
@@ -9,6 +9,7 @@ use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
persons::{Name, Person},
|
||||
@@ -20,7 +21,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub async fn page(
|
||||
State(state): State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
Path(id): Path<Uuid>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
@@ -106,7 +107,7 @@ pub struct AddNameForm {
|
||||
}
|
||||
|
||||
pub async fn add_name(
|
||||
State(state): State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
Path(id): Path<Uuid>,
|
||||
headers: HeaderMap,
|
||||
Form(form): Form<AddNameForm>,
|
||||
@@ -134,7 +135,7 @@ pub async fn add_name(
|
||||
}
|
||||
|
||||
pub async fn delete_name(
|
||||
State(state): State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
Path(id): Path<Uuid>,
|
||||
headers: HeaderMap,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use axum::{
|
||||
extract::{Query, Request},
|
||||
extract::{Query, Request, State},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
use maud::{PreEscaped, html};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
quotes::Quote,
|
||||
users::{User, auth::UserAuthenticate},
|
||||
@@ -24,7 +25,7 @@ pub struct PageQuery {
|
||||
}
|
||||
|
||||
pub async fn page(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
Query(query): Query<PageQuery>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use axum::{
|
||||
extract::Request,
|
||||
extract::{Request, State},
|
||||
http::HeaderMap,
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
@@ -10,6 +10,7 @@ use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
persons::Name,
|
||||
@@ -25,7 +26,7 @@ const LINE_ADD_RM_SCRIPT: &str = include_str!("line-add-rm.js");
|
||||
const PREFILL_TIME_SCRIPT: &str = include_str!("prefill-time.js");
|
||||
|
||||
pub async fn page(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let mut conn = state.pool.acquire().await?;
|
||||
@@ -141,7 +142,7 @@ pub struct IncomingQuote {
|
||||
context: String,
|
||||
}
|
||||
pub async fn form(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
headers: HeaderMap,
|
||||
Form(form): Form<IncomingQuote>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use axum::{
|
||||
Form,
|
||||
extract::{Path, Request},
|
||||
extract::{Path, Request, State},
|
||||
http::HeaderMap,
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
@@ -9,6 +9,7 @@ use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
tags::{Tag, TagName},
|
||||
@@ -20,7 +21,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub async fn page(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let mut conn = state.pool.acquire().await?;
|
||||
@@ -116,7 +117,7 @@ pub struct TagForm {
|
||||
tagname: TagName,
|
||||
}
|
||||
pub async fn create(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
headers: HeaderMap,
|
||||
Form(form): Form<TagForm>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
@@ -138,7 +139,7 @@ pub async fn create(
|
||||
}
|
||||
|
||||
pub async fn delete_tag(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
Path(id): Path<Uuid>,
|
||||
headers: HeaderMap,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use axum::{
|
||||
extract::Request,
|
||||
extract::{Request, State},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
use maud::{PreEscaped, html};
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
users::{User, auth::UserAuthenticate, permissions::Permission},
|
||||
web::{
|
||||
@@ -18,7 +19,7 @@ pub mod create;
|
||||
pub mod profile;
|
||||
|
||||
pub async fn page(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let mut conn = state.pool.acquire().await?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use axum::{
|
||||
Form,
|
||||
extract::Request,
|
||||
extract::{Request, State},
|
||||
http::{HeaderMap, StatusCode},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
@@ -8,6 +8,7 @@ use maud::{PreEscaped, html};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
logs::{LogAction, LogEntry},
|
||||
users::{
|
||||
@@ -20,7 +21,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub async fn page(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let mut conn = state.pool.acquire().await?;
|
||||
@@ -73,7 +74,7 @@ pub struct CreateUserWithPasswordForm {
|
||||
password: String,
|
||||
}
|
||||
pub async fn create_user(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
headers: HeaderMap,
|
||||
Form(form): Form<CreateUserWithPasswordForm>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use axum::{
|
||||
extract::{Path, Request},
|
||||
extract::{Path, Request, State},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
use maud::{PreEscaped, html};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
MnemoState,
|
||||
error::CompositeError,
|
||||
users::{User, UserError, auth::UserAuthenticate},
|
||||
web::{
|
||||
@@ -16,7 +17,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub async fn page(
|
||||
axum::extract::State(state): axum::extract::State<crate::MnemoState>,
|
||||
State(state): State<MnemoState>,
|
||||
Path(id): Path<Uuid>,
|
||||
req: Request,
|
||||
) -> Result<Response, CompositeError> {
|
||||
|
||||
Reference in New Issue
Block a user