You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I want to implement server-side auth with actix framework, which is normally done by middlewares. Currently Leptos supports defining axum middlewares, like in the following example:
I tried to implement the necessary traits in server_fn/src/middleware/mod.rs for actix's middleware to work in the same way, but found it's not possible.
The reason is that actix's middleware, which implements actix_service::Transform trait, is actually a "service-generating factory", and it generates the wrapping Service (or the Transform component) asynchronously. However, Leptos's Layer trait works in synchronous way.
Describe the solution you'd like
Be able to use #[middleware] macros for actix's server functions, just like middlewares for axum's server functions
Describe alternatives you've considered
I can call handle_server_fns() method from leptos-actix, and register the returned Route manually. But this has two drawbacks:
Redundant routes in actix, since leptos-actix already did this:
I spent a while trying to implement this before 0.6, and kept running into "X does not implement Y" trait errors that I wasn't able to figure out, not being familiar at all with Actix middleware. Very open to any changes to server_fns that need to happen to make it work.
Is your feature request related to a problem? Please describe.
I want to implement server-side auth with actix framework, which is normally done by middlewares. Currently Leptos supports defining axum middlewares, like in the following example:
leptos/examples/server_fns_axum/src/app.rs
Lines 249 to 257 in 97fd8ff
leptos/examples/server_fns_axum/src/middleware.rs
Lines 9 to 28 in 97fd8ff
I tried to implement the necessary traits in
server_fn/src/middleware/mod.rs
for actix's middleware to work in the same way, but found it's not possible.The reason is that actix's middleware, which implements
actix_service::Transform
trait, is actually a "service-generating factory", and it generates the wrapping Service (or the Transform component) asynchronously. However, Leptos'sLayer
trait works in synchronous way.Describe the solution you'd like
Be able to use
#[middleware]
macros for actix's server functions, just like middlewares for axum's server functionsDescribe alternatives you've considered
I can call
handle_server_fns()
method fromleptos-actix
, and register the returnedRoute
manually. But this has two drawbacks:leptos-actix
already did this:leptos/integrations/actix/src/lib.rs
Lines 1275 to 1280 in 97fd8ff
Additional context
Here is how I tried to implement it in my fork
sify21@4381aad
The text was updated successfully, but these errors were encountered: