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

Publicly use actix_web::app_service::AppEntry as actix_web::AppEntry #2082

Closed
wants to merge 1 commit into from
Closed

Publicly use actix_web::app_service::AppEntry as actix_web::AppEntry #2082

wants to merge 1 commit into from

Conversation

kotovalexarian
Copy link

This allows Actix users to move application to separate function. This may be useful when application is big.

use actix_web::{get, App, AppEntry, HttpResponse, HttpServer, Responder};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| app())
        .bind("127.0.0.1:8000")?
        .run()
        .await
}

fn app() -> actix_web::App<AppEntry, actix_web::body::Body> {
    App::new()
        .service(index)
}

#[get("/")]
fn index() -> impl Responder {
    HttpResponse::Ok().body("Hello, World!")
}

@robjtede robjtede closed this Mar 17, 2021
@robjtede
Copy link
Member

App is not designed to be used directly.

Search AppEntry in closed issues to find more info.

@fakeshadow
Copy link
Contributor

No this can not. You can check the reason and how to properly return an App instance here
#2039 (comment)

AppEntry is only the default type of App and it would mutate to some opaque type in your code. Exposing it would be not useful at all.

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

Successfully merging this pull request may close these issues.

3 participants