fix(db): register custom API routes before the Leptos server function handler
This commit is contained in:
parent
e46b693e56
commit
0ac35c3ca5
1 changed files with 7 additions and 4 deletions
|
@ -32,6 +32,12 @@ async fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
|
// Register custom API routes BEFORE Leptos server functions
|
||||||
|
.service(
|
||||||
|
web::scope("/api")
|
||||||
|
.route("/items", web::get().to(get_items))
|
||||||
|
.route("/items", web::post().to(create_item)),
|
||||||
|
)
|
||||||
// Register server functions
|
// Register server functions
|
||||||
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
|
.route("/api/{tail:.*}", leptos_actix::handle_server_fns())
|
||||||
// Serve JS/WASM/CSS from `pkg`
|
// Serve JS/WASM/CSS from `pkg`
|
||||||
|
@ -47,9 +53,6 @@ async fn main() -> std::io::Result<()> {
|
||||||
//.wrap(middleware::Compress::default())
|
//.wrap(middleware::Compress::default())
|
||||||
// Pass the database as shared state
|
// Pass the database as shared state
|
||||||
.app_data(web::Data::new(db))
|
.app_data(web::Data::new(db))
|
||||||
// Register API endpoints
|
|
||||||
.route("/api/items", web::get().to(get_items))
|
|
||||||
.route("/api/items", web::post().to(create_item))
|
|
||||||
})
|
})
|
||||||
.bind(&addr)?
|
.bind(&addr)?
|
||||||
.run()
|
.run()
|
||||||
|
|
Loading…
Add table
Reference in a new issue