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

Expose AppEntry for more friendly ergonomics/further impl capabilities #3033

Closed
Wolftousen opened this issue May 11, 2023 · 2 comments
Closed

Comments

@Wolftousen
Copy link

Your issue may already be reported! Please search on the Actix Web issue tracker before creating one.

Expected Behavior

AppEntry is publicly exposed so that App can be further implemented.

Current Behavior

Currently, AppEntry is not exposed publicly and makes the following impossible:

//several routes defined above

pub trait LibARouter {
    fn register_liba_routes(self) -> Self;
}

impl LibARouter for App<AppEntry> {
    fn register_liba_routes(self) -> Self {
        self.service(route_a)
            .service(route_b)
            .service(route_c)
    }
}

Context

I'm currently working on a project to build a rather robust REST API and I'm splitting my route handler functions out into several files. We'll be expanding out to more routes in the future and we want to have minimal changes to the App::new() code. So we thought about doing the code snippet above in each route file to accomplish that. It would also help with ergonomics in general.

This is sort of the like the plugin functionality that bevy uses in it's builder.

Your Environment

  • Rust Version (I.e, output of rustc -V): 1.69.0
  • Actix Web Version: 4.3.1
@robjtede
Copy link
Member

robjtede commented May 11, 2023

Duplicate or related to: #780 #1005 #1156 #2039 #2073 #2082 #2301

@robjtede
Copy link
Member

robjtede commented May 11, 2023

Here's how to return App from a fn with v4.x:

fn can_be_returned_from_fn() {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants