fix: исправлены роуты веб-сервера и обновлён Makefile
- Убран дублирующийся роут /favicon.ico - Добавлен импорт ServeDir - Makefile: поддержка ImageMagick 6 и 7 - Добавлена цель favicon
This commit is contained in:
27
src/web.rs
27
src/web.rs
@@ -89,13 +89,16 @@ pub async fn run_web_server(config: Config) -> anyhow::Result<()> {
|
||||
.route("/favicon.ico", get(favicon))
|
||||
.route("/static/style.css", get(style_css))
|
||||
.route("/static/fontawesome/all.min.css", get(fontawesome_css))
|
||||
.nest_service("/static/fontawesome/webfonts", ServeDir::new("src/static/fontawesome/webfonts"))
|
||||
.route("/assets/logo.png", get(logo_png))
|
||||
.route("/api/jobs", get(list_jobs))
|
||||
.route("/api/generate", post(generate_jobs))
|
||||
.route("/api/cleanup", post(cleanup_jobs))
|
||||
.route("/api/status", get(get_status))
|
||||
.route("/api/jobs/stop-all", post(stop_all_jobs))
|
||||
.nest_service(
|
||||
"/static/fontawesome/webfonts",
|
||||
ServeDir::new("src/static/fontawesome/webfonts"),
|
||||
)
|
||||
.layer(TraceLayer::new_for_http())
|
||||
.with_state(state);
|
||||
|
||||
@@ -112,19 +115,31 @@ async fn index_page() -> Html<&'static str> {
|
||||
}
|
||||
|
||||
async fn style_css() -> impl IntoResponse {
|
||||
([(CONTENT_TYPE, "text/css")], include_str!("static/style.css"))
|
||||
(
|
||||
[(CONTENT_TYPE, "text/css")],
|
||||
include_str!("static/style.css"),
|
||||
)
|
||||
}
|
||||
|
||||
async fn fontawesome_css() -> impl IntoResponse {
|
||||
([(CONTENT_TYPE, "text/css")], include_str!("static/fontawesome/all.min.css"))
|
||||
(
|
||||
[(CONTENT_TYPE, "text/css")],
|
||||
include_str!("static/fontawesome/all.min.css"),
|
||||
)
|
||||
}
|
||||
|
||||
async fn logo_png() -> impl IntoResponse {
|
||||
([(CONTENT_TYPE, "image/png")], include_bytes!("../assets/logo.png").as_slice())
|
||||
(
|
||||
[(CONTENT_TYPE, "image/png")],
|
||||
include_bytes!("../assets/logo.png").as_slice(),
|
||||
)
|
||||
}
|
||||
|
||||
async fn favicon() -> impl IntoResponse {
|
||||
([(CONTENT_TYPE, "image/png")], include_bytes!("../assets/logo.png").as_slice())
|
||||
(
|
||||
[(CONTENT_TYPE, "image/x-icon")],
|
||||
include_bytes!("static/favicon.ico").as_slice(),
|
||||
)
|
||||
}
|
||||
|
||||
async fn list_jobs(State(state): State<AppState>) -> Result<Json<Vec<JobInfo>>, AppError> {
|
||||
@@ -220,4 +235,4 @@ impl IntoResponse for AppError {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
(self.0, self.1).into_response()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user