add server function middleware

This commit is contained in:
Evan Almloff committed 2023-07-07 18:25:45 -07:00
1 parent c49c75cb60
commit 14883bb711
12 files changed
+446 -171

No files matched your search

@@ -14,6 +14,7 @@ axum = { version = "0.6.12", optional = true }
tokio = { workspace = true, features = ["full"], optional = true }
serde = "1.0.159"
execute = "0.2.12"
tower-http = { version = "0.4.1", features = ["auth"] }
[features]
default = []
@@ -41,9 +41,9 @@ fn app(cx: Scope<AppProps>) -> Element {
}
#[server(PostServerData)]
#[middleware(Auth(AuthLevel::Admin))]
#[middleware(tower_http::validate_request::ValidateRequestHeaderLayer::bearer("passwordlol"))]
async fn post_server_data(
#[extract] Axum(axum::extract::Host(host), _): Axum<_, _>,
#[extract] axum::extract::Host(host): axum::extract::Host,
data: String,
) -> Result<(), ServerFnError> {
println!("Server received: {}", data);