Extractors allow you to wrap your server function in some code that changes either the request or the response. Dioxus fullstack integrates with Tower to allow you to wrap your server functions in middleware.

You can use the #[middleware] attribute to add a layer of middleware to your server function. Let's add a timeout middleware to a server function. This middleware will stop running the server function if it reaches a certain timeout:

// Add a timeout middleware to the server function that will return an error if the function takes longer than 1 second to execute
pub async fn timeout() -> Result<(), ServerFnError> {