1
0
Fork 0

cargo fix & fmt

This commit is contained in:
Adrian Hedqvist 2022-09-05 00:05:24 +02:00
parent e0237555cd
commit 982a642d17
3 changed files with 26 additions and 29 deletions

View file

@ -3,12 +3,9 @@ use std::sync::Arc;
use tracing::log::*;
use axum::{
extract::Path,
response::{Html, IntoResponse, Response},
http::{StatusCode, Uri},
Extension,
};
use pulldown_cmark::{html, Options, Parser};
use crate::State;

View file

@ -1,16 +1,13 @@
use std::sync::Arc;
use axum::{extract::Path, Extension, response::Html};
use pulldown_cmark::{Options, Parser, html};
use axum::{extract::Path, response::Html, Extension};
use pulldown_cmark::{html, Options, Parser};
use tracing::log::*;
use crate::{State, handlers::PageContext};
use super::{Result, Error};
use super::{Error, Result};
use crate::{handlers::PageContext, State};
pub async fn view(
Path(slug): Path<String>,
Extension(state): Extension<Arc<State>>,
) -> Result {
pub async fn view(Path(slug): Path<String>, Extension(state): Extension<Arc<State>>) -> Result {
let post = state
.posts
.iter()

View file

@ -1,6 +1,11 @@
use std::{path::PathBuf, sync::Arc};
use std::sync::Arc;
use axum::{routing::{get, get_service}, Extension, Router, handler::Handler, http::StatusCode};
use axum::{
handler::Handler,
http::StatusCode,
routing::{get, get_service},
Extension, Router,
};
use color_eyre::eyre::Result;
use glob::glob;
use serde_derive::Serialize;
@ -32,18 +37,18 @@ async fn main() -> Result<()> {
.map(|p| {
let path = p.unwrap();
let filename = path
.file_name()
.unwrap()
.to_string_lossy();
let filename = path.file_name().unwrap().to_string_lossy();
let (filename, _) = filename.rsplit_once('.')
.unwrap();
let (filename, _) = filename.rsplit_once('.').unwrap();
let slug = if filename.eq_ignore_ascii_case("index") {
path.parent().unwrap().file_name().unwrap().to_string_lossy().into_owned()
}
else {
path.parent()
.unwrap()
.file_name()
.unwrap()
.to_string_lossy()
.into_owned()
} else {
filename.to_owned()
};
@ -64,9 +69,11 @@ async fn main() -> Result<()> {
.route("/", get(handlers::index))
.route("/posts/", get(handlers::posts::index))
.route("/posts/:slug/", get(handlers::posts::view))
.nest("/static", get_service(tower_http::services::ServeDir::new("./static")).handle_error(|e| async {
(StatusCode::NOT_FOUND, "not found")
}))
.nest(
"/static",
get_service(tower_http::services::ServeDir::new("./static"))
.handle_error(|_e| async { (StatusCode::NOT_FOUND, "not found") }),
)
.fallback((|| async { (StatusCode::NOT_FOUND, "not found") }).into_service())
.layer(middleware);
@ -78,7 +85,3 @@ async fn main() -> Result<()> {
Ok(())
}
async fn healthcheck() -> &'static str {
"OK"
}