Actix-web: App data is not configured

I'm using an actix-web server as a visualizer for my simulator. It's been running with actix-web 1.0 for a long time, but I decided to update it to 2.0. Converting the client in the simulator went fine, but I've hit a wall with the server. The code compiles, but no matter what I do, I get

App data is not configured, to configure use App::data()

when I click the one button on the web page.

Here's a small(ish) case that causes the error.

async fn main() {
    let index_data = web::Data::new("index.html"); 
    let geo_data = web::Data::new(geometry::AppGeometry::default());
    let hello_data = web::Data::new(hello::AppCells::default());
    HttpServer::new(move || {


replay::post() uses AppGeometry and AppCells, but it isn't small.

I've searched web, and I tried data instead of app_data.

What is your replay::post() signature?

It should use web::Data<geometry::AppGeometry> as argument type.

Sorry, I need to actually look at my code before posting. replay::post() just defines the route. It is replay_from_data() that uses AppGeometry and AppCells.

pub fn post() -> Scope {
        .route("", web::post().to(replay_from_data))

Looking at the code, I see I have a .data() statement. I have no idea why it's there. I probably cribbed it from somewhere when I wrote the version for actix-web 1.0. Removing that statement solved the problem

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.