let app = actix_web::App::new()
.data(ctx.clone())
.wrap(some_middleware)
.wrap(other_middleware)
.configure(configure_server)
.default_service(web::resource("").route(web::get().to(default_404)));
With this I can share all the initialization of the routes, but I'm forced to duplicate the middleware initialization and the default_service.
But well the wrap middlewares system is nice, so I guess that's a tradeoff with the typesystem.
But I'm blocked at the next step.
Before I had a helper around actix_web::test::TestServer to ease the use of the TestServer (bringing some asserts and parsing of the results).
What seems to be the actix v1 equivalent is actix_web::test::init_service(app), but I don't see a way to store the resulting service as the resulting type is a bit complex
Problem migrating tests to 1.0
Hi,
I'm migrating a project from 0.7 to 1.0 and I'm quite happy with the migration, great work!
The only things I'm stumbling upon are migrating the integration tests.
I don't know if that's really idiomatic, but for our integration tests we used the same App creation as for the real server.
To do this, the app creation was in a function returing
App<Context>
.then in main:
and in tests:
Now that the App type depends on the middleware I don't know the new return type for the
create_server
function.Following some advice from gitter, I used App::configure:
then in main:
And in test:
With this I can share all the initialization of the routes, but I'm forced to duplicate the middleware initialization and the
default_service
. But well thewrap
middlewares system is nice, so I guess that's a tradeoff with the typesystem.But I'm blocked at the next step.
Before I had a helper around
actix_web::test::TestServer
to ease the use of theTestServer
(bringing some asserts and parsing of the results).actix v0.7:
What seems to be the actix v1 equivalent is
actix_web::test::init_service(app)
, but I don't see a way to store the resulting service as the resulting type is a bit complexI'm far from being a rust expert and I'm stuck to know the concrete type of the service
I tried boxing it but I fail the know all the sub types of
NewService
(especially theResponse
)What is the right course of action for this ? Is it not idiomatic to want to make a wrapper around the test service ?