Skip to content

Commit 746f80d

Browse files
authored
feat: support admin actions through HTTP interface (#244)
* Rename hotfix-status to hotfix-http * Move endpoints into separate modules * Add admin endpoints * Update test suite for hotfix-http * Create new hotfix-dashboard project * Break out dashboard crate for UI functionality * Rename data provider to session controller * Rename hotfix-http to hotfix-web * Rename hotfix-dashboard to hotfix-web-ui * Update example app with new terminology for web interface * Apply rustfmt * Add test cases for hotfix-web-ui
1 parent cdcdb57 commit 746f80d

30 files changed

Lines changed: 739 additions & 303 deletions

File tree

Cargo.lock

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hotfix-status/src/api.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

crates/hotfix-status/src/data_provider.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

crates/hotfix-status/src/lib.rs

Lines changed: 0 additions & 176 deletions
This file was deleted.

crates/hotfix-status/src/ui.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

crates/hotfix-web-ui/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "hotfix-web-ui"
3+
description = "Web dashboard UI components for the HotFIX engine"
4+
version = "0.1.0"
5+
authors.workspace = true
6+
edition.workspace = true
7+
license.workspace = true
8+
readme.workspace = true
9+
homepage.workspace = true
10+
repository.workspace = true
11+
keywords.workspace = true
12+
categories.workspace = true
13+
14+
[dependencies]
15+
hotfix = { version = "0.3.0", path = "../hotfix" }
16+
17+
anyhow = { workspace = true }
18+
askama = { workspace = true, features = ["serde_json"] }
19+
async-trait = { workspace = true }
20+
axum = { workspace = true }
21+
chrono = { workspace = true }
22+
displaydoc = { workspace = true }
23+
mime_guess = { workspace = true }
24+
rust-embed = { workspace = true, features = ["axum-ex"] }
25+
thiserror = { workspace = true }
26+
27+
[dev-dependencies]
28+
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
29+
tower = { workspace = true }
30+
31+
[lints]
32+
workspace = true
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
use axum::http::{StatusCode, Uri, header};
1+
use axum::extract::Path;
2+
use axum::http::{StatusCode, header};
23
use axum::response::{IntoResponse, Response};
34
use rust_embed::Embed;
45

56
#[derive(Embed)]
67
#[folder = "assets/"]
78
struct Assets;
89

9-
pub(crate) async fn static_handler(uri: Uri) -> impl IntoResponse {
10-
let mut path = uri.path().trim_start_matches('/').to_string();
11-
12-
if path.starts_with("static/") {
13-
path = path.replace("static/", "");
14-
}
15-
10+
pub(crate) async fn static_handler(Path(path): Path<String>) -> impl IntoResponse {
1611
StaticFile(path)
1712
}
1813

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use crate::AppState;
2-
use crate::data_provider::DataProvider;
3-
use crate::error::AppResult;
1+
use crate::SessionInfoProvider;
2+
use crate::error::DashboardResult;
43
use askama::Template;
5-
use axum::extract::State;
4+
use axum::extract::{FromRef, State};
65
use axum::response::{Html, IntoResponse};
76
use chrono::Utc;
87
use hotfix::session::SessionInfo;
@@ -16,10 +15,14 @@ struct DashboardTemplate<'a> {
1615
timestamp_string: &'a str,
1716
}
1817

19-
pub(crate) async fn dashboard_handler<P: DataProvider>(
20-
State(state): State<AppState<P>>,
21-
) -> AppResult<impl IntoResponse> {
22-
let session_info = state.data_provider.get_session_info().await?;
18+
pub(crate) async fn dashboard_handler<S, P>(
19+
State(provider): State<P>,
20+
) -> DashboardResult<impl IntoResponse>
21+
where
22+
S: Clone + Send + Sync + 'static,
23+
P: SessionInfoProvider + FromRef<S>,
24+
{
25+
let session_info = provider.get_session_info().await?;
2326
let timestamp_string = Utc::now().to_rfc3339();
2427

2528
let template = DashboardTemplate {

0 commit comments

Comments
 (0)