feat(axum): register checked handles

Add HandlerRegistry::register_handle for generated Handle<T> values and migrate examples away from passing raw numeric handle ids at registration sites.

req: ceremony/004

req: public_api/001
This commit is contained in:
slhx agent
2026-05-26 00:26:42 +02:00
parent 4803d681d2
commit bc8534a768
5 changed files with 34 additions and 21 deletions
+5 -5
View File
@@ -116,7 +116,7 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
HandlerRegistry::new(ui::BUILD_FINGERPRINT)
.register(ui::counter::handles::increment.id().id, {
.register_handle(ui::counter::handles::increment, {
let state = state.clone();
move |_| {
// req: examples/001
@@ -125,7 +125,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
ui::counter::slots::counter_value.text(*counter)
}
})
.register(ui::todos::handles::add_todo.id().id, {
.register_handle(ui::todos::handles::add_todo, {
let state = state.clone();
move |form| {
// req: examples/001
@@ -141,7 +141,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
)
}
})
.register(ui::wizard::handles::next_step.id().id, {
.register_handle(ui::wizard::handles::next_step, {
let state = state.clone();
move |_| {
// req: examples/001
@@ -150,7 +150,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
ui::wizard::slots::wizard_step.text(format!("Step {}", *step + 1))
}
})
.register(ui::auth::handles::login.id().id, |form| {
.register_handle(ui::auth::handles::login, |form| {
// req: examples/001
let ok = form.value("email") == Some("demo@example.com")
&& form.value("password").is_some_and(|password| !password.is_empty());
@@ -160,7 +160,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
"Try demo@example.com with any password"
})
})
.register(ui::page_swap::handles::load_docs.id().id, |_| {
.register_handle(ui::page_swap::handles::load_docs, |_| {
// req: page_swap/002, req: examples/001
(
ui::page_swap::slots::content.html(render_docs_content(