Compare commits
2 Commits
8efd8c8021
...
2d5c7f3d2a
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d5c7f3d2a | |||
| acfdfb03f5 |
@ -230,6 +230,7 @@ fn detect_format(path: &str) -> ImageFmt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// detect_format 的轻量返回类型,避免在热路径上构造 image::ImageFormat。
|
/// detect_format 的轻量返回类型,避免在热路径上构造 image::ImageFormat。
|
||||||
|
#[cfg(feature = "server")]
|
||||||
type ImageFmt = image::ImageFormat;
|
type ImageFmt = image::ImageFormat;
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
|||||||
@ -42,9 +42,9 @@ mod tiptap_bridge;
|
|||||||
// codemirror_bridge:SQL 编辑器的 wasm-bindgen 绑定,结构镜像 tiptap_bridge。
|
// codemirror_bridge:SQL 编辑器的 wasm-bindgen 绑定,结构镜像 tiptap_bridge。
|
||||||
// 共享类型(SqlSchema/SqlTable)两端都编译;extern 与 EditorHandle 在 #[cfg(wasm32)] 子模块里。
|
// 共享类型(SqlSchema/SqlTable)两端都编译;extern 与 EditorHandle 在 #[cfg(wasm32)] 子模块里。
|
||||||
mod codemirror_bridge;
|
mod codemirror_bridge;
|
||||||
mod xterm_bridge;
|
|
||||||
mod utils;
|
mod utils;
|
||||||
mod webp;
|
mod webp;
|
||||||
|
mod xterm_bridge;
|
||||||
|
|
||||||
/// 压缩算法配置。
|
/// 压缩算法配置。
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
@ -231,10 +231,10 @@ async fn admin_guard(
|
|||||||
req: axum::extract::Request,
|
req: axum::extract::Request,
|
||||||
next: axum::middleware::Next,
|
next: axum::middleware::Next,
|
||||||
) -> axum::response::Response {
|
) -> axum::response::Response {
|
||||||
|
use crate::models::user::UserRole;
|
||||||
use axum::body::Body;
|
use axum::body::Body;
|
||||||
use axum::http::{header, StatusCode};
|
use axum::http::{header, StatusCode};
|
||||||
use axum::response::Response;
|
use axum::response::Response;
|
||||||
use crate::models::user::UserRole;
|
|
||||||
|
|
||||||
let path = req.uri().path().to_string();
|
let path = req.uri().path().to_string();
|
||||||
if !path.starts_with("/admin") {
|
if !path.starts_with("/admin") {
|
||||||
@ -289,7 +289,6 @@ fn main() {
|
|||||||
// 必须在 tracing 初始化之后,否则日志被丢弃。
|
// 必须在 tracing 初始化之后,否则日志被丢弃。
|
||||||
build_info::log_build_info();
|
build_info::log_build_info();
|
||||||
|
|
||||||
|
|
||||||
// 校验数据库连接串,未设置则直接退出
|
// 校验数据库连接串,未设置则直接退出
|
||||||
if std::env::var("DATABASE_URL").is_err() {
|
if std::env::var("DATABASE_URL").is_err() {
|
||||||
tracing::error!("DATABASE_URL environment variable not set. Make sure .env exists or the variable is exported.");
|
tracing::error!("DATABASE_URL environment variable not set. Make sure .env exists or the variable is exported.");
|
||||||
@ -506,8 +505,7 @@ fn main() {
|
|||||||
));
|
));
|
||||||
// admin_guard 置于最外层(最后添加 = 最先执行):未登录的 /admin* 请求
|
// admin_guard 置于最外层(最后添加 = 最先执行):未登录的 /admin* 请求
|
||||||
// 在 CSRF / cache / SSR 渲染之前就被 302 短路,零渲染开销。
|
// 在 CSRF / cache / SSR 渲染之前就被 302 短路,零渲染开销。
|
||||||
let app_routes =
|
let app_routes = app_routes.layer(axum::middleware::from_fn(admin_guard));
|
||||||
app_routes.layer(axum::middleware::from_fn(admin_guard));
|
|
||||||
|
|
||||||
// 静态资源路由:图片文件服务。
|
// 静态资源路由:图片文件服务。
|
||||||
// 注意:`dioxus::server::serve()` 接管了 listener 与 `into_make_service`
|
// 注意:`dioxus::server::serve()` 接管了 listener 与 `into_make_service`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user