Would you prefer a single app or multiple apps


#1

I recently tried actix-web framework but I am confused about how to use actix-web properly.

Should I use multiple app (*example from actix-web doc)

let server = server::new(|| {
    vec![
        App::new()
            .prefix("/app1")
            .resource("/", |r| r.f(|r| HttpResponse::Ok())),
        App::new()
            .prefix("/app2")
            .resource("/", |r| r.f(|r| HttpResponse::Ok())),
        App::new().resource("/", |r| r.f(|r| HttpResponse::Ok())),
    ]
});

or single app

App::new().scope("/project", |proj_scope| {
    proj_scope
        .resource("", |r| {
            r.method(Method::GET).f(get_projects);
            r.method(Method::POST).f(create_project)
        })
        .resource("/{project_id}", |r| {
            r.method(Method::PUT).with(update_project);
            r.method(Method::DELETE).f(delete_project)
        })
        .nested("/{project_id}/task", |task_scope| {
            task_scope
                .resource("", |r| {
                    r.method(Method::GET).f(get_tasks);
                    r.method(Method::POST).f(create_task)
                })
                .resource("/{task_id}", |r| {
                    r.method(Method::PUT).with(update_task);
                    r.method(Method::DELETE).with(delete_task)
                })
        })
}).scope("/user" ?????)
    .scope(????)

#2

It’s up to you, but most likely single app will be enough, so keep it simple. The only reason to have multiple app I can think of is if you want to have them to store different states (beside splitting them for better code organisation).