Skip to content

Commit df4d5d1

Browse files
feat(shield-dioxus): add integration and route (#127)
1 parent 7089dcc commit df4d5d1

20 files changed

Lines changed: 799 additions & 240 deletions

File tree

Cargo.lock

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

examples/dioxus-axum/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ web = ["dioxus/web"]
3030
axum = { workspace = true, optional = true }
3131
dioxus = { workspace = true, features = ["router", "fullstack"] }
3232
shield.workspace = true
33+
shield-dioxus.workspace = true
3334
shield-dioxus-axum = { workspace = true, optional = true }
3435
shield-memory = { workspace = true, optional = true }
3536
shield-oidc = { workspace = true, features = ["native-tls"], optional = true }

examples/dioxus-axum/src/app.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
use dioxus::prelude::*;
2+
use shield_dioxus::ShieldRouter;
23

34
use crate::home::Home;
45

5-
#[derive(Debug, Clone, Routable, PartialEq)]
6+
#[derive(Clone, Debug, PartialEq, Routable)]
67
#[rustfmt::skip]
78
enum Route {
89
#[route("/")]
910
Home {},
11+
#[child("/auth")]
12+
Auth {
13+
child: ShieldRouter
14+
},
1015
}
1116

1217
#[component]

examples/dioxus-axum/src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ async fn main() {
1919
prelude::{DioxusRouterExt, *},
2020
};
2121
use shield::{Shield, ShieldOptions};
22-
use shield_dioxus_axum::ShieldLayer;
23-
use shield_memory::MemoryStorage;
22+
use shield_dioxus_axum::{ShieldLayer, provide_axum_integration};
23+
use shield_memory::{MemoryStorage, User};
2424
use shield_oidc::{Keycloak, OidcMethod};
2525
use tokio::net::TcpListener;
2626
use tower_sessions::{Expiry, MemoryStore, SessionManagerLayer, cookie::time::Duration};
@@ -59,7 +59,13 @@ async fn main() {
5959

6060
// Initialize router
6161
let router = Router::new()
62-
.serve_dioxus_application(ServeConfig::new().unwrap(), App)
62+
.serve_dioxus_application(
63+
ServeConfigBuilder::new()
64+
.context_provider(provide_axum_integration::<User>)
65+
.build()
66+
.unwrap(),
67+
App,
68+
)
6369
.layer(shield_layer)
6470
.layer(session_layer);
6571

0 commit comments

Comments
 (0)