1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-01 13:37:49 +00:00

Make it work

This commit is contained in:
RGBCube 2024-01-08 10:07:32 +03:00
parent 52783348df
commit 019e1c7091
No known key found for this signature in database
5 changed files with 49 additions and 41 deletions

13
Cargo.lock generated
View file

@ -147,6 +147,7 @@ checksum = "d09dbe0e490df5da9d69b36dca48a76635288a82f92eca90024883a56202026d"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum-core", "axum-core",
"axum-macros",
"bytes", "bytes",
"futures-util", "futures-util",
"http", "http",
@ -194,6 +195,18 @@ dependencies = [
"tracing", "tracing",
] ]
[[package]]
name = "axum-macros"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a2edad600410b905404c594e2523549f1bcd4bded1e252c8f74524ccce0b867"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "axum-server" name = "axum-server"
version = "0.6.0" version = "0.6.0"

View file

@ -9,23 +9,23 @@ repositoty = "https://github.com/RGBCube/rgbcube.github.io"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
anyhow = "1.0.77" anyhow = "1.0.77"
axum = "0.7.3" axum = { version = "0.7.3", features = [ "macros" ] }
axum-server = { version = "0.6.0", features = [ "tls-rustls" ] } axum-server = { version = "0.6.0", features = [ "tls-rustls" ] }
bytes = "1.5.0" bytes = "1.5.0"
cargo_toml = "0.17.2" cargo_toml = "0.17.2"
chrono = "0.4.31" chrono = "0.4.31"
clap = { version = "4.4.12", features = [ "derive" ] } clap = { version = "4.4.12", features = [ "derive" ] }
embed = { git = "https://github.com/RGBCube/embed-rs" } embed = { git = "https://github.com/RGBCube/embed-rs" }
env_logger = "0.10.1" env_logger = "0.10.1"
log = { version = "0.4.20", features = [ "serde" ] } log = { version = "0.4.20", features = [ "serde" ] }
maud = { git = "https://github.com/lambda-fairy/maud", features = [ "axum" ] } maud = { git = "https://github.com/lambda-fairy/maud", features = [ "axum" ] }
mime_guess = "2.0.4" mime_guess = "2.0.4"
minify-js = "0.6.0" minify-js = "0.6.0"
pulldown-cmark = "0.9.3" pulldown-cmark = "0.9.3"
tokio = { version = "1.35.1", features = [ "full" ] } tokio = { version = "1.35.1", features = [ "full" ] }
tower = "0.4.13" tower = "0.4.13"
tower-http = { version = "0.5.0", features = [ "trace" ] } tower-http = { version = "0.5.0", features = [ "trace" ] }
[patch.crates-io] [patch.crates-io]
proc-macro2 = { git = "https://github.com/RGBCube/proc-macro2" } proc-macro2 = { git = "https://github.com/RGBCube/proc-macro2" }

View file

@ -1,8 +1,8 @@
use std::array; use std::array;
use actix_web::{ use axum::{
dev::ServiceResponse, http::StatusCode,
middleware::ErrorHandlerResponse, BoxError,
}; };
use maud::html; use maud::html;
@ -11,12 +11,9 @@ use crate::{
page::cube, page::cube,
}; };
pub fn handler<B: 'static>( pub async fn handler(_: BoxError) -> (StatusCode, String) {
response: ServiceResponse<B>, (
) -> actix_web::Result<ErrorHandlerResponse<B>> { StatusCode::INTERNAL_SERVER_ERROR,
let (request, response) = response.into_parts();
let response = response.set_body(
cube::create( cube::create(
Some("Error"), Some("Error"),
asset::Css::Shared("cube-grid.css"), asset::Css::Shared("cube-grid.css"),
@ -32,11 +29,5 @@ pub fn handler<B: 'static>(
}), }),
) )
.into_string(), .into_string(),
); )
Ok(ErrorHandlerResponse::Response(
ServiceResponse::new(request, response)
.map_into_boxed_body()
.map_into_right_body(),
))
} }

View file

@ -1,11 +1,15 @@
use axum::Router; use axum::{
// error_handling::HandleErrorLayer,
Router,
};
// use tower::ServiceBuilder;
mod internal_server_error; // mod internal_server_error;
mod not_found; mod not_found;
pub fn handler<B: 'static>() -> ErrorHandlers<B> { pub fn router() -> Router {
Router::new().fallback(not_found::handler).handler( Router::new().fallback(not_found::handler)
StatusCode::INTERNAL_SERVER_ERROR, // TODO
internal_server_error::handler, // .layer(ServiceBuilder::new().
) // layer(HandleErrorLayer::new(internal_server_error::handler)))
} }

View file

@ -10,7 +10,7 @@ use crate::{
page::cube, page::cube,
}; };
pub fn handler() -> Markup { pub async fn handler() -> Markup {
cube::create( cube::create(
Some("404"), Some("404"),
asset::Css::Shared("cube-grid.css"), asset::Css::Shared("cube-grid.css"),