1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00

Update json/jsonrpc to v4 (#491)

This commit is contained in:
Luca Palmieri 2022-02-02 15:16:19 +00:00 committed by GitHub
parent 5dec713add
commit 71899bf343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

6
Cargo.lock generated
View File

@ -3218,9 +3218,9 @@ dependencies = [
name = "jsonrpc-example" name = "jsonrpc-example"
version = "1.0.0" version = "1.0.0"
dependencies = [ dependencies = [
"actix-web 3.3.3", "actix-web 4.0.0-beta.21",
"bytes 0.5.6", "bytes 1.1.0",
"env_logger 0.8.4", "env_logger 0.9.0",
"futures-util", "futures-util",
"log", "log",
"serde 1.0.136", "serde 1.0.136",

View File

@ -4,11 +4,11 @@ version = "1.0.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
actix-web = "3" actix-web = "4.0.0-beta.21"
bytes = "0.5" bytes = "1.1.0"
env_logger = "0.8" env_logger = "0.9.0"
futures-util = "0.3" futures-util = "0.3"
log = "0.4" log = "0.4"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0.78"

View File

@ -119,7 +119,7 @@ impl ImplNetwork for ObjNetwork {
d: u64, d: u64,
) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn error::Error>>>>> { ) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn error::Error>>>>> {
async move { async move {
actix_web::rt::time::delay_for(Duration::from_secs(d)).await; actix_web::rt::time::sleep(Duration::from_secs(d)).await;
Ok(String::from("pong")) Ok(String::from("pong"))
} }
.boxed_local() .boxed_local()
@ -155,7 +155,7 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(move || { HttpServer::new(move || {
let app_state = AppState::new(network.clone()); let app_state = AppState::new(network.clone());
App::new() App::new()
.data(app_state) .app_data(web::Data::new(app_state))
.wrap(middleware::Logger::default()) .wrap(middleware::Logger::default())
.service(web::resource("/").route(web::post().to(rpc_handler))) .service(web::resource("/").route(web::post().to(rpc_handler)))
}) })