Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[middleware] tag to allow the selective targeting of Tower services on Server Fns #1461

Closed
benwis opened this issue Jul 29, 2023 · 3 comments
Labels
enhancement New feature or request feature request

Comments

@benwis
Copy link
Contributor

benwis commented Jul 29, 2023

@Demonthos and I talked about Diouxs's use of middleware of middleware on server functions. The example given looks like this:

#[server]
// Add a timeout middleware to the server function that will return an error if the function takes longer than 1 second to execute
#[middleware(tower_http::timeout::TimeoutLayer::new(std::time::Duration::from_secs(1)))]
pub async fn timeout() -> Result<(), ServerFnError> {
    tokio::time::sleep(std::time::Duration::from_secs(2)).await;
    Ok(())
}

And is implemented in Dioxus here:
https://github.com/DioxusLabs/dioxus/blob/master/packages/fullstack/src/adapters/mod.rs

This is only supported for Dioxus on the Tower based platforms, so Actix support would be unlikely here. It might necessitate the creation of separate Actix and Axum server function crates.

I'd love to see this as an option in the Axum Leptos version

@gbj gbj added the enhancement New feature or request label Jul 29, 2023
@sumitdethe27
Copy link

I want to work on this issue ,
Please assign me

@benwis
Copy link
Contributor Author

benwis commented Aug 5, 2023

I want to work on this issue , Please assign me

You're welcome to work on this, let me or @gbj know if you have any questions

@benwis benwis changed the title Add #[metadata] tag to allow the selective targeting of Tower services on Server Fns Add #[iddleware] tag to allow the selective targeting of Tower services on Server Fns Dec 15, 2023
@benwis benwis changed the title Add #[iddleware] tag to allow the selective targeting of Tower services on Server Fns Add #[middleware] tag to allow the selective targeting of Tower services on Server Fns Dec 15, 2023
@gbj gbj mentioned this issue Jan 4, 2024
20 tasks
@gbj
Copy link
Collaborator

gbj commented Jan 20, 2024

#[middleware] macro for Tower layers added in #2158.

@gbj gbj closed this as completed Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

No branches or pull requests

3 participants