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

[Feature request]: More Axum features support #526

Open
livstyle opened this issue Feb 7, 2025 · 1 comment
Open

[Feature request]: More Axum features support #526

livstyle opened this issue Feb 7, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request rust Requires rust knowledge

Comments

@livstyle
Copy link

livstyle commented Feb 7, 2025

Is your feature request related to a problem? Please describe.

I want to use axum's layer, but currently, it only supports with_state. If support is added in the future, what would the implementation approach look like? Currently, the code generates main.rs through text replacement. Would it be better for users to create main.rs themselves and use macros to add additional information to the main function?

Describe the solution you'd like

use reqwest::Client;

#[derive(Clone)]
pub struct ApplicationState {
    pub fetch: Client,
}

#[tuono::main]
#[tokio::main]
pub fn main() -> tuono::Result<()> {
    let fetch = Client::new();
    let app_state ApplicationState { fetch };
    let middlewares = vec![];
    tuono::run(app_state, middlewares)
}

Describe alternatives you've considered

No response

Additional context

No response

@livstyle livstyle added the enhancement New feature or request label Feb 7, 2025
@Valerioageno
Copy link
Member

Hey! Thanks for raising this.
I already have something in mind, and I'd love to hear your thoughts on it.

I think the best would be to create a new middleware.rs file. Every file in the same folder or in a nested one are going to be affected by the middleware.

i.e. src/routes/middleware.rs affects all the application endpoints and src/routes/protected/middleware.rs affects just the /protected/* endpoints.

Would that address your suggestion?
We already have a ticket for it in the backlog.

@Valerioageno Valerioageno self-assigned this Feb 7, 2025
@Valerioageno Valerioageno added the rust Requires rust knowledge label Feb 7, 2025
@github-project-automation github-project-automation bot moved this to Backlog in Road to V1 Feb 7, 2025
@Valerioageno Valerioageno removed this from Road to V1 Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rust Requires rust knowledge
Projects
None yet
Development

No branches or pull requests

2 participants