mirror of
https://github.com/zaphar/Heracles.git
synced 2025-07-23 04:29:48 -04:00
fix: type signatures for the state passing.
This commit is contained in:
parent
bb856bb464
commit
4d2524efdc
@ -66,7 +66,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
.nest("/api", routes::mk_api_routes(config.clone()))
|
||||
// HTMX ui component endpoints
|
||||
.nest("/ui", routes::mk_ui_routes(config.clone()))
|
||||
.route("/", get(routes::index).with_state(config.clone()))
|
||||
.route("/", get(routes::index).with_state(State(config.clone())))
|
||||
.layer(TraceLayer::new_for_http())
|
||||
.with_state(State(config.clone()));
|
||||
let socket_addr = args.listen.unwrap_or("127.0.0.1:3000".to_string());
|
||||
|
@ -58,11 +58,20 @@ pub fn mk_api_routes(config: Arc<Vec<Dashboard>>) -> Router<Config> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mk_ui_routes(config: Arc<Vec<Dashboard>>) -> Router<Config> {
|
||||
Router::new()
|
||||
pub async fn dash_ui(State(config): State<Config>, Path(idx): Path<usize>) -> Markup {
|
||||
html!(
|
||||
"TODO(jwall): Fill this in"
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn index(State(config): Config) -> Markup {
|
||||
pub fn mk_ui_routes(config: Arc<Vec<Dashboard>>) -> Router<Config> {
|
||||
Router::new().route(
|
||||
"/dash/:idx",
|
||||
get(dash_ui).with_state(State(config))
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn index(State(config): State<Config>) -> Markup {
|
||||
html! {
|
||||
html {
|
||||
head {
|
||||
@ -76,7 +85,7 @@ pub async fn index(State(config): Config) -> Markup {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn app(State(config): Config) -> Markup {
|
||||
pub async fn app(State(config): State<Config>) -> Markup {
|
||||
let titles = config
|
||||
.iter()
|
||||
.map(|d| d.title.clone())
|
||||
@ -87,7 +96,7 @@ pub async fn app(State(config): Config) -> Markup {
|
||||
// Header menu
|
||||
ul {
|
||||
@for title in &titles {
|
||||
li hx-get=(format!("/ui/dash/{}/", title.0)) hx-target="#dashboard" { (title.1) }
|
||||
li hx-get=(format!("/ui/dash/{}", title.0)) hx-target="#dashboard" { (title.1) }
|
||||
}
|
||||
}
|
||||
// dashboard display
|
||||
|
Loading…
x
Reference in New Issue
Block a user