Changes .data by .app_data in actix example to prevent deprecation msg #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The example was previously currently working, but if you search today for actix-web on the web, the first link will send you to the actix-web v4.4.1. The
.data()
documentation says the method is deprecated: https://docs.rs/actix-web/4.4.1/actix_web/struct.App.html#method.dataFirst time I tried to run the actix example, I didn't know how to test the example and see the
Hello, world!
message on my browser. I've got really confused by reading the link above because it didn't match the function I was reading on the source code. With the code changes on this PR, I think it will be easier for a new comer to understand what the example does if the example contains the.app_data
function instead of the.data()
function.v3.2.0 source code
data: https://github.com/actix/actix-web/blob/42f51eb962af48b85b944fe64d24f4a81ad4650e/src/app.rs#L103
app_data: https://github.com/actix/actix-web/blob/42f51eb962af48b85b944fe64d24f4a81ad4650e/src/app.rs#L146
v4.4.0 source deo
data: https://github.com/actix/actix-web/blob/e50bceb91493087d4059e605d94c13a11b09e747/actix-web/src/app.rs#L124
app_data: https://github.com/actix/actix-web/blob/e50bceb91493087d4059e605d94c13a11b09e747/actix-web/src/app.rs#L115
NOTE: If you just attempt to update the application to version 4.4.0 or 4.0.0 you will get a panick error telling you there is
no reactor running. But I guess that's a different problem
Link to v3.3.0 documentation
thread 'main' panicked at 'there is no reactor running, must be called from the context of Tokio runtime', /home/karl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-0.2.24/src/io/driver/mod.rs:204:14
note: run with
RUST_BACKTRACE=1
environment variable to display a backtrace[JS] Worker [id: 25506 port: 9000]: Node.js version: v18.16.1
[JS] Worker [id: 25506 port: 9000]: Uncaught Exception: Error: listen EADDRINUSE: address already in use :::9000