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