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

Changes .data by .app_data in actix example to prevent deprecation msg #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KarlHeitmann
Copy link

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.data

First 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

no_reactor_running_error

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

The example was previously currently working, but if you search today
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.data

The code changes on this commit will prevent this deprecation message to
appear if the crate is upgraded to 4.x version in the future
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.

1 participant