1
0
mirror of https://github.com/actix/examples synced 2025-03-31 07:52:32 +02:00

chore: fmt

This commit is contained in:
Rob Ede 2025-03-21 06:07:31 +00:00
parent a7527d72f3
commit 04f8cba71b
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
98 changed files with 828 additions and 650 deletions

1105
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
use std::io; use std::io;
use actix_web::{middleware, web, App, HttpResponse, HttpServer}; use actix_web::{App, HttpResponse, HttpServer, middleware, web};
use casbin::{CoreApi, DefaultModel, Enforcer, FileAdapter, RbacApi}; use casbin::{CoreApi, DefaultModel, Enforcer, FileAdapter, RbacApi};
/// simple handle /// simple handle

View File

@ -1,10 +1,11 @@
use actix_identity::{Identity, IdentityMiddleware}; use actix_identity::{Identity, IdentityMiddleware};
use actix_session::{config::PersistentSession, storage::CookieSessionStore, SessionMiddleware}; use actix_session::{SessionMiddleware, config::PersistentSession, storage::CookieSessionStore};
use actix_web::{ use actix_web::{
cookie::{time::Duration, Key}, App, HttpMessage as _, HttpRequest, HttpServer, Responder,
cookie::{Key, time::Duration},
error, error,
http::StatusCode, http::StatusCode,
middleware, web, App, HttpMessage as _, HttpRequest, HttpServer, Responder, middleware, web,
}; };
const ONE_MINUTE: Duration = Duration::minutes(1); const ONE_MINUTE: Duration = Duration::minutes(1);

View File

@ -6,12 +6,13 @@
//! [User guide](https://actix.rs/docs/middleware/#user-sessions) //! [User guide](https://actix.rs/docs/middleware/#user-sessions)
use actix_session::{ use actix_session::{
config::PersistentSession, storage::CookieSessionStore, Session, SessionMiddleware, Session, SessionMiddleware, config::PersistentSession, storage::CookieSessionStore,
}; };
use actix_web::{ use actix_web::{
App, HttpRequest, HttpServer, Result,
cookie::{self, Key}, cookie::{self, Key},
middleware::Logger, middleware::Logger,
web, App, HttpRequest, HttpServer, Result, web,
}; };
/// simple index handler with session /// simple index handler with session

View File

@ -4,11 +4,10 @@
//! At login, the session key changes and session state in cache re-assigns. //! At login, the session key changes and session state in cache re-assigns.
//! At logout, session state in cache is removed and cookie is invalidated. //! At logout, session state in cache is removed and cookie is invalidated.
use actix_session::{storage::RedisSessionStore, Session, SessionMiddleware}; use actix_session::{Session, SessionMiddleware, storage::RedisSessionStore};
use actix_web::{ use actix_web::{
middleware, web, App, HttpResponse, HttpServer, Result, middleware, web,
web::{get, post, resource}, web::{get, post, resource},
App, HttpResponse, HttpServer, Result,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -1,8 +1,8 @@
use std::future::{ready, Ready}; use std::future::{Ready, ready};
use actix_identity::Identity; use actix_identity::Identity;
use actix_web::{ use actix_web::{
dev::Payload, web, Error, FromRequest, HttpMessage as _, HttpRequest, HttpResponse, Error, FromRequest, HttpMessage as _, HttpRequest, HttpResponse, dev::Payload, web,
}; };
use diesel::prelude::*; use diesel::prelude::*;
use serde::Deserialize; use serde::Deserialize;

View File

@ -1,4 +1,4 @@
use actix_web::{web, HttpResponse}; use actix_web::{HttpResponse, web};
use diesel::prelude::*; use diesel::prelude::*;
use serde::Deserialize; use serde::Deserialize;

View File

@ -2,8 +2,8 @@
extern crate diesel; extern crate diesel;
use actix_identity::IdentityMiddleware; use actix_identity::IdentityMiddleware;
use actix_session::{config::PersistentSession, storage::CookieSessionStore, SessionMiddleware}; use actix_session::{SessionMiddleware, config::PersistentSession, storage::CookieSessionStore};
use actix_web::{cookie::Key, middleware, web, App, HttpServer}; use actix_web::{App, HttpServer, cookie::Key, middleware, web};
use diesel::{prelude::*, r2d2}; use diesel::{prelude::*, r2d2};
use time::Duration; use time::Duration;

View File

@ -1,7 +1,7 @@
#![allow(clippy::extra_unused_lifetimes)] #![allow(clippy::extra_unused_lifetimes)]
use chrono::{NaiveDateTime, TimeDelta, Utc}; use chrono::{NaiveDateTime, TimeDelta, Utc};
use diesel::{r2d2::ConnectionManager, PgConnection}; use diesel::{PgConnection, r2d2::ConnectionManager};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use uuid::Uuid; use uuid::Uuid;

View File

@ -1,4 +1,4 @@
use actix_web::{web, HttpResponse}; use actix_web::{HttpResponse, web};
use diesel::prelude::*; use diesel::prelude::*;
use serde::Deserialize; use serde::Deserialize;
use uuid::Uuid; use uuid::Uuid;

View File

@ -3,7 +3,7 @@ use std::{
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };
use actix_web::{web::Data, App, HttpServer}; use actix_web::{App, HttpServer, web::Data};
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
mod ephemeral_jobs; mod ephemeral_jobs;

View File

@ -1,14 +1,13 @@
use actix_web::{ use actix_web::{
error, get, post, HttpResponse, Responder, error, get, post,
web::{self, Data}, web::{self, Data},
HttpResponse, Responder,
}; };
use apalis::prelude::*; use apalis::prelude::*;
use apalis_redis::RedisStorage; use apalis_redis::RedisStorage;
use chrono::{TimeDelta, Utc}; use chrono::{TimeDelta, Utc};
use serde::Deserialize; use serde::Deserialize;
use crate::{persistent_jobs::Email, ItemCache}; use crate::{ItemCache, persistent_jobs::Email};
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub(crate) struct CacheInsert { pub(crate) struct CacheInsert {

View File

@ -1,14 +1,14 @@
use std::{convert::Infallible, io}; use std::{convert::Infallible, io};
use actix_files::{Files, NamedFile}; use actix_files::{Files, NamedFile};
use actix_session::{storage::CookieSessionStore, Session, SessionMiddleware}; use actix_session::{Session, SessionMiddleware, storage::CookieSessionStore};
use actix_web::{ use actix_web::{
error, get, App, Either, HttpRequest, HttpResponse, HttpServer, Responder, Result, error, get,
http::{ http::{
header::{self, ContentType},
Method, StatusCode, Method, StatusCode,
header::{self, ContentType},
}, },
middleware, web, App, Either, HttpRequest, HttpResponse, HttpServer, Responder, Result, middleware, web,
}; };
use actix_web_lab::extract::Path; use actix_web_lab::extract::Path;
use async_stream::stream; use async_stream::stream;

View File

@ -12,11 +12,11 @@ http errors will be chosen, each with an equal chance of being selected:
*/ */
use actix_web::{web, App, Error, HttpResponse, HttpServer, ResponseError}; use actix_web::{App, Error, HttpResponse, HttpServer, ResponseError, web};
use derive_more::Display; use derive_more::Display;
use rand::{ use rand::{
distr::{Distribution, StandardUniform},
Rng, Rng,
distr::{Distribution, StandardUniform},
}; };
#[derive(Debug, Display)] #[derive(Debug, Display)]

View File

@ -1,4 +1,4 @@
use actix_web::{middleware, web, App, HttpRequest, HttpServer}; use actix_web::{App, HttpRequest, HttpServer, middleware, web};
async fn index(req: HttpRequest) -> &'static str { async fn index(req: HttpRequest) -> &'static str {
println!("REQ: {req:?}"); println!("REQ: {req:?}");
@ -25,7 +25,7 @@ async fn main() -> std::io::Result<()> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use actix_web::{body::to_bytes, dev::Service, http, test, Error}; use actix_web::{Error, body::to_bytes, dev::Service, http, test};
use super::*; use super::*;

View File

@ -1,4 +1,4 @@
use actix_web::{web, Error, HttpResponse}; use actix_web::{Error, HttpResponse, web};
use crate::common::{Part, Product}; use crate::common::{Part, Product};

View File

@ -1,4 +1,4 @@
use actix_web::{web, Error, HttpResponse}; use actix_web::{Error, HttpResponse, web};
use crate::common::{Part, Product}; use crate::common::{Part, Product};
@ -21,9 +21,10 @@ pub async fn remove_product(_id: web::Path<String>) -> Result<HttpResponse, Erro
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use actix_web::{ use actix_web::{
App,
dev::Service, dev::Service,
http::{header, StatusCode}, http::{StatusCode, header},
test, App, test,
}; };
use crate::app_config::config_app; use crate::app_config::config_app;

View File

@ -1,4 +1,4 @@
use actix_web::{middleware, App, HttpServer}; use actix_web::{App, HttpServer, middleware};
use nested_routing::app_config::config_app; use nested_routing::app_config::config_app;
#[actix_web::main] #[actix_web::main]

View File

@ -22,15 +22,14 @@ use std::{
cell::Cell, cell::Cell,
io, io,
sync::{ sync::{
atomic::{AtomicUsize, Ordering},
Mutex, Mutex,
atomic::{AtomicUsize, Ordering},
}, },
}; };
use actix_web::{ use actix_web::{
middleware, App, HttpRequest, HttpResponse, HttpServer, middleware,
web::{self, Data}, web::{self, Data},
App, HttpRequest, HttpResponse, HttpServer,
}; };
/// simple handle /// simple handle

View File

@ -1,5 +1,5 @@
use actix_files::Files; use actix_files::Files;
use actix_web::{middleware::Logger, App, HttpServer}; use actix_web::{App, HttpServer, middleware::Logger};
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {

View File

@ -1,8 +1,8 @@
use actix_files::NamedFile; use actix_files::NamedFile;
use actix_session::Session; use actix_session::Session;
use actix_web::{ use actix_web::{
dev, error, http::StatusCode, middleware::ErrorHandlerResponse, web, Error, HttpResponse, Error, HttpResponse, Responder, Result, dev, error, http::StatusCode,
Responder, Result, middleware::ErrorHandlerResponse, web,
}; };
use serde::Deserialize; use serde::Deserialize;
use sqlx::SqlitePool; use sqlx::SqlitePool;

View File

@ -1,11 +1,11 @@
use std::{env, io}; use std::{env, io};
use actix_files::Files; use actix_files::Files;
use actix_session::{storage::CookieSessionStore, SessionMiddleware}; use actix_session::{SessionMiddleware, storage::CookieSessionStore};
use actix_web::{ use actix_web::{
http, App, HttpServer, http,
middleware::{ErrorHandlers, Logger}, middleware::{ErrorHandlers, Logger},
web, App, HttpServer, web,
}; };
use dotenvy::dotenv; use dotenvy::dotenv;
use tera::Tera; use tera::Tera;

View File

@ -1,7 +1,7 @@
use std::io; use std::io;
use actix_cors::Cors; use actix_cors::Cors;
use actix_web::{http::header, middleware::Logger, App, HttpServer}; use actix_web::{App, HttpServer, http::header, middleware::Logger};
mod user; mod user;

View File

@ -1,4 +1,4 @@
use actix_web::{web, App, HttpResponse, HttpServer}; use actix_web::{App, HttpResponse, HttpServer, web};
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {

View File

@ -6,7 +6,7 @@
#[macro_use] #[macro_use]
extern crate diesel; extern crate diesel;
use actix_web::{error, get, middleware, post, web, App, HttpResponse, HttpServer, Responder}; use actix_web::{App, HttpResponse, HttpServer, Responder, error, get, middleware, post, web};
use diesel::{prelude::*, r2d2}; use diesel::{prelude::*, r2d2};
use uuid::Uuid; use uuid::Uuid;

View File

@ -4,9 +4,9 @@ mod model;
#[cfg(test)] #[cfg(test)]
mod test; mod test;
use actix_web::{get, post, web, App, HttpResponse, HttpServer}; use actix_web::{App, HttpResponse, HttpServer, get, post, web};
use model::User; use model::User;
use mongodb::{bson::doc, options::IndexOptions, Client, Collection, IndexModel}; use mongodb::{Client, Collection, IndexModel, bson::doc, options::IndexOptions};
const DB_NAME: &str = "myApp"; const DB_NAME: &str = "myApp";
const COLL_NAME: &str = "users"; const COLL_NAME: &str = "users";

View File

@ -1,5 +1,5 @@
use actix_web::{ use actix_web::{
test::{call_and_read_body, call_and_read_body_json, init_service, TestRequest}, test::{TestRequest, call_and_read_body, call_and_read_body_json, init_service},
web::Bytes, web::Bytes,
}; };

View File

@ -1,6 +1,6 @@
use std::{env, io}; use std::{env, io};
use actix_web::{web, App, HttpServer}; use actix_web::{App, HttpServer, web};
mod models; mod models;
mod persistence; mod persistence;

View File

@ -1,4 +1,4 @@
use actix_web::{get, post, web, HttpResponse, Responder}; use actix_web::{HttpResponse, Responder, get, post, web};
use crate::{ use crate::{
models::{BankData, BranchData, CustomerData, TellerData}, models::{BankData, BranchData, CustomerData, TellerData},

View File

@ -1,4 +1,4 @@
use actix_web::{web, App, Error, HttpResponse, HttpServer}; use actix_web::{App, Error, HttpResponse, HttpServer, web};
use confik::{Configuration as _, EnvSource}; use confik::{Configuration as _, EnvSource};
use deadpool_postgres::{Client, Pool}; use deadpool_postgres::{Client, Pool};
use dotenvy::dotenv; use dotenvy::dotenv;

View File

@ -1,6 +1,6 @@
use std::io; use std::io;
use actix_web::{error, middleware, web, App, HttpResponse, HttpServer, Responder}; use actix_web::{App, HttpResponse, HttpServer, Responder, error, middleware, web};
use serde::Deserialize; use serde::Deserialize;
async fn get_from_cache(redis: web::Data<redis::Client>) -> actix_web::Result<impl Responder> { async fn get_from_cache(redis: web::Data<redis::Client>) -> actix_web::Result<impl Responder> {

View File

@ -1,4 +1,4 @@
use actix_web::{get, middleware::Logger, App, HttpResponse, HttpServer, Responder}; use actix_web::{App, HttpResponse, HttpServer, Responder, get, middleware::Logger};
#[get("/")] #[get("/")]
async fn index() -> impl Responder { async fn index() -> impl Responder {

View File

@ -1,4 +1,4 @@
use actix_web::{middleware, web, App, HttpRequest, HttpResponse, HttpServer, Responder, Result}; use actix_web::{App, HttpRequest, HttpResponse, HttpServer, Responder, Result, middleware, web};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
struct AppState { struct AppState {
@ -74,8 +74,8 @@ mod tests {
body::to_bytes, body::to_bytes,
dev::ServiceResponse, dev::ServiceResponse,
http::{ http::{
header::{HeaderValue, CONTENT_TYPE},
StatusCode, StatusCode,
header::{CONTENT_TYPE, HeaderValue},
}, },
test::{self, TestRequest}, test::{self, TestRequest},
web::{Bytes, Form}, web::{Bytes, Form},

View File

@ -1,8 +1,8 @@
use std::env; use std::env;
use aws_config::SdkConfig as AwsConfig; use aws_config::SdkConfig as AwsConfig;
use aws_sdk_s3::{primitives::ByteStream, Client as S3Client}; use aws_sdk_s3::{Client as S3Client, primitives::ByteStream};
use futures_util::{stream, StreamExt as _}; use futures_util::{StreamExt as _, stream};
use tokio::{fs, io::AsyncReadExt as _}; use tokio::{fs, io::AsyncReadExt as _};
use crate::{TempFile, UploadedFile}; use crate::{TempFile, UploadedFile};

View File

@ -1,14 +1,14 @@
use std::{fs, io}; use std::{fs, io};
use actix_multipart::form::{tempfile::TempFile, text::Text, MultipartForm}; use actix_multipart::form::{MultipartForm, tempfile::TempFile, text::Text};
use actix_web::{ use actix_web::{
body::SizedStream, delete, error, get, http::Method, middleware::Logger, post, route, web, App, App, Error, HttpResponse, HttpServer, Responder, body::SizedStream, delete, error, get,
Error, HttpResponse, HttpServer, Responder, http::Method, middleware::Logger, post, route, web,
}; };
use actix_web_lab::extract::Path; use actix_web_lab::extract::Path;
use aws_config::{meta::region::RegionProviderChain, BehaviorVersion}; use aws_config::{BehaviorVersion, meta::region::RegionProviderChain};
use dotenvy::dotenv; use dotenvy::dotenv;
use futures_util::{stream, StreamExt as _}; use futures_util::{StreamExt as _, stream};
use serde_json::json; use serde_json::json;
use tokio_util::io::ReaderStream; use tokio_util::io::ReaderStream;

View File

@ -1,13 +1,13 @@
use std::io::Write; use std::io::Write;
use actix_multipart::{ use actix_multipart::{
form::{
tempfile::{TempFile, TempFileConfig},
MultipartForm,
},
Multipart, Multipart,
form::{
MultipartForm,
tempfile::{TempFile, TempFileConfig},
},
}; };
use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer, Responder}; use actix_web::{App, Error, HttpResponse, HttpServer, Responder, middleware, web};
use futures_util::TryStreamExt as _; use futures_util::TryStreamExt as _;
use uuid::Uuid; use uuid::Uuid;

View File

@ -1,8 +1,8 @@
use actix_cors::Cors; use actix_cors::Cors;
use actix_web::{get, middleware::Logger, route, web, App, HttpServer, Responder}; use actix_web::{App, HttpServer, Responder, get, middleware::Logger, route, web};
use async_graphql::{ use async_graphql::{
http::{playground_source, GraphQLPlaygroundConfig},
EmptyMutation, EmptySubscription, Schema, EmptyMutation, EmptySubscription, Schema,
http::{GraphQLPlaygroundConfig, playground_source},
}; };
use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse}; use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse};

View File

@ -1,6 +1,6 @@
use async_graphql::{ use async_graphql::{
connection::{query, Connection, Edge},
Context, Enum, Error, Interface, Object, OutputType, Result, Context, Enum, Error, Interface, Object, OutputType, Result,
connection::{Connection, Edge, query},
}; };
use super::{StarWars, StarWarsChar}; use super::{StarWars, StarWarsChar};

View File

@ -1,6 +1,6 @@
use r2d2_mysql::{ use r2d2_mysql::{
mysql::{Opts, OptsBuilder},
MySqlConnectionManager, MySqlConnectionManager,
mysql::{Opts, OptsBuilder},
}; };
pub type Pool = r2d2::Pool<MySqlConnectionManager>; pub type Pool = r2d2::Pool<MySqlConnectionManager>;

View File

@ -1,9 +1,9 @@
use actix_web::{get, route, web, Error, HttpResponse, Responder}; use actix_web::{Error, HttpResponse, Responder, get, route, web};
use juniper::http::{graphiql::graphiql_source, GraphQLRequest}; use juniper::http::{GraphQLRequest, graphiql::graphiql_source};
use crate::{ use crate::{
db::Pool, db::Pool,
schemas::root::{create_schema, Context, Schema}, schemas::root::{Context, Schema, create_schema},
}; };
/// GraphQL endpoint /// GraphQL endpoint

View File

@ -1,5 +1,5 @@
use actix_cors::Cors; use actix_cors::Cors;
use actix_web::{middleware::Logger, web::Data, App, HttpServer}; use actix_web::{App, HttpServer, middleware::Logger, web::Data};
mod db; mod db;
mod handlers; mod handlers;

View File

@ -1,5 +1,5 @@
use juniper::GraphQLInputObject; use juniper::GraphQLInputObject;
use mysql::{from_row, params, prelude::*, Error as DBError, Row}; use mysql::{Error as DBError, Row, from_row, params, prelude::*};
use crate::schemas::{root::Context, user::User}; use crate::schemas::{root::Context, user::User};

View File

@ -1,7 +1,7 @@
use juniper::{ use juniper::{
graphql_object, graphql_value, EmptySubscription, FieldError, FieldResult, RootNode, EmptySubscription, FieldError, FieldResult, RootNode, graphql_object, graphql_value,
}; };
use mysql::{from_row, params, prelude::*, Error as DBError, Row}; use mysql::{Error as DBError, Row, from_row, params, prelude::*};
use super::{ use super::{
product::{Product, ProductInput}, product::{Product, ProductInput},

View File

@ -1,5 +1,5 @@
use juniper::{graphql_object, GraphQLInputObject}; use juniper::{GraphQLInputObject, graphql_object};
use mysql::{from_row, params, prelude::*, Row}; use mysql::{Row, from_row, params, prelude::*};
use crate::schemas::{product::Product, root::Context}; use crate::schemas::{product::Product, root::Context};

View File

@ -6,15 +6,14 @@ use std::{io, sync::Arc};
use actix_cors::Cors; use actix_cors::Cors;
use actix_web::{ use actix_web::{
get, middleware, route, App, HttpResponse, HttpServer, Responder, get, middleware, route,
web::{self, Data}, web::{self, Data},
App, HttpResponse, HttpServer, Responder,
}; };
use juniper::http::{graphiql::graphiql_source, GraphQLRequest}; use juniper::http::{GraphQLRequest, graphiql::graphiql_source};
mod schema; mod schema;
use crate::schema::{create_schema, Schema}; use crate::schema::{Schema, create_schema};
/// GraphiQL playground UI /// GraphiQL playground UI
#[get("/graphiql")] #[get("/graphiql")]

View File

@ -1,10 +1,11 @@
use actix_web::{ use actix_web::{
App, Error, HttpServer, Responder,
body::MessageBody, body::MessageBody,
dev::{ServiceFactory, ServiceRequest, ServiceResponse}, dev::{ServiceFactory, ServiceRequest, ServiceResponse},
get, get,
guard::{Guard, GuardContext}, guard::{Guard, GuardContext},
middleware::DefaultHeaders, middleware::DefaultHeaders,
web, App, Error, HttpServer, Responder, web,
}; };
mod v1 { mod v1 {

View File

@ -1,7 +1,7 @@
use std::{io, net::ToSocketAddrs as _}; use std::{io, net::ToSocketAddrs as _};
use actix_web::{ use actix_web::{
dev::PeerAddr, error, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, App, Error, HttpRequest, HttpResponse, HttpServer, dev::PeerAddr, error, middleware, web,
}; };
use awc::Client; use awc::Client;
use clap::Parser; use clap::Parser;

View File

@ -1,8 +1,8 @@
use std::time::Duration; use std::time::Duration;
use acme::{create_p256_key, Certificate, Directory, DirectoryUrl}; use acme::{Certificate, Directory, DirectoryUrl, create_p256_key};
use actix_files::Files; use actix_files::Files;
use actix_web::{rt, web, App, HttpRequest, HttpServer, Responder}; use actix_web::{App, HttpRequest, HttpServer, Responder, rt, web};
use eyre::eyre; use eyre::eyre;
use rustls::pki_types::{PrivateKeyDer, PrivatePkcs8KeyDer}; use rustls::pki_types::{PrivateKeyDer, PrivatePkcs8KeyDer};
use tokio::fs; use tokio::fs;

View File

@ -1,7 +1,7 @@
use std::{sync::Arc, time::Instant}; use std::{sync::Arc, time::Instant};
use actix_web::{get, middleware, web::Data, App, HttpResponse, HttpServer}; use actix_web::{App, HttpResponse, HttpServer, get, middleware, web::Data};
use awc::{http::header, Client, Connector}; use awc::{Client, Connector, http::header};
use rustls::{ClientConfig, RootCertStore}; use rustls::{ClientConfig, RootCertStore};
const MAP_URL: &str = const MAP_URL: &str =

View File

@ -1,11 +1,11 @@
use std::{fs::File, io::BufReader, path::Path}; use std::{fs::File, io::BufReader, path::Path};
use actix_web::{ use actix_web::{
http::header::ContentType, middleware, web, App, HttpRequest, HttpResponse, HttpServer, App, HttpRequest, HttpResponse, HttpServer, http::header::ContentType, middleware, web,
}; };
use log::debug; use log::debug;
use notify::{Event, RecursiveMode, Watcher as _}; use notify::{Event, RecursiveMode, Watcher as _};
use rustls::{pki_types::PrivateKeyDer, ServerConfig}; use rustls::{ServerConfig, pki_types::PrivateKeyDer};
use rustls_pemfile::{certs, pkcs8_private_keys}; use rustls_pemfile::{certs, pkcs8_private_keys};
use tokio::sync::mpsc; use tokio::sync::mpsc;

View File

@ -3,7 +3,7 @@ use std::{
io::{self, Read as _}, io::{self, Read as _},
}; };
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer}; use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, middleware, web};
use openssl::{ use openssl::{
pkey::{PKey, Private}, pkey::{PKey, Private},
ssl::{SslAcceptor, SslMethod}, ssl::{SslAcceptor, SslMethod},

View File

@ -5,13 +5,13 @@ use std::{any::Any, fs::File, io::BufReader, net::SocketAddr, sync::Arc};
use actix_tls::accept::rustls_0_23::TlsStream; use actix_tls::accept::rustls_0_23::TlsStream;
use actix_web::{ use actix_web::{
dev::Extensions, rt::net::TcpStream, web, App, HttpRequest, HttpResponse, HttpServer, Responder, App, HttpRequest, HttpResponse, HttpServer, Responder, dev::Extensions, rt::net::TcpStream, web,
}; };
use log::info; use log::info;
use rustls::{ use rustls::{
RootCertStore, ServerConfig,
pki_types::{CertificateDer, PrivateKeyDer}, pki_types::{CertificateDer, PrivateKeyDer},
server::WebPkiClientVerifier, server::WebPkiClientVerifier,
RootCertStore, ServerConfig,
}; };
use rustls_pemfile::{certs, pkcs8_private_keys}; use rustls_pemfile::{certs, pkcs8_private_keys};

View File

@ -2,10 +2,10 @@ use std::{fs::File, io::BufReader};
use actix_files::Files; use actix_files::Files;
use actix_web::{ use actix_web::{
http::header::ContentType, middleware, web, App, HttpRequest, HttpResponse, HttpServer, App, HttpRequest, HttpResponse, HttpServer, http::header::ContentType, middleware, web,
}; };
use log::debug; use log::debug;
use rustls::{pki_types::PrivateKeyDer, ServerConfig}; use rustls::{ServerConfig, pki_types::PrivateKeyDer};
use rustls_pemfile::{certs, pkcs8_private_keys}; use rustls_pemfile::{certs, pkcs8_private_keys};
/// simple handle /// simple handle

View File

@ -1,4 +1,4 @@
use actix_web::{error, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder}; use actix_web::{App, HttpRequest, HttpResponse, HttpServer, Responder, error, post, web};
use serde::Deserialize; use serde::Deserialize;
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View File

@ -2,7 +2,7 @@
use std::{fmt, io}; use std::{fmt, io};
use actix_web::{http::StatusCode, web, App, HttpResponse, HttpServer, ResponseError}; use actix_web::{App, HttpResponse, HttpServer, ResponseError, http::StatusCode, web};
use serde::Serialize; use serde::Serialize;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]

View File

@ -15,9 +15,9 @@
use std::io; use std::io;
use actix_web::{ use actix_web::{
App, Error, HttpResponse, HttpServer,
error::ErrorBadRequest, error::ErrorBadRequest,
web::{self, BytesMut}, web::{self, BytesMut},
App, Error, HttpResponse, HttpServer,
}; };
use awc::Client; use awc::Client;
use futures_util::StreamExt as _; use futures_util::StreamExt as _;

View File

@ -1,4 +1,4 @@
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer}; use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, middleware, web};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]

View File

@ -1,11 +1,11 @@
use actix_web::{ use actix_web::{
App, Error, HttpServer, Responder,
body::{self, MessageBody}, body::{self, MessageBody},
dev::{self, ServiceResponse}, dev::{self, ServiceResponse},
middleware::{from_fn, Logger, Next}, middleware::{Logger, Next, from_fn},
web::{self, Data, Json}, web::{self, Data, Json},
App, Error, HttpServer, Responder,
}; };
use aes_gcm_siv::{aead::Aead as _, Aes256GcmSiv, KeyInit as _, Nonce}; use aes_gcm_siv::{Aes256GcmSiv, KeyInit as _, Nonce, aead::Aead as _};
use base64::prelude::*; use base64::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -1,8 +1,8 @@
use std::{fs::File, io::BufReader}; use std::{fs::File, io::BufReader};
use actix_web::{dev::Service, get, http, App, HttpResponse, HttpServer}; use actix_web::{App, HttpResponse, HttpServer, dev::Service, get, http};
use futures_util::future::{self, Either, FutureExt}; use futures_util::future::{self, Either, FutureExt};
use rustls::{pki_types::PrivateKeyDer, ServerConfig}; use rustls::{ServerConfig, pki_types::PrivateKeyDer};
use rustls_pemfile::{certs, pkcs8_private_keys}; use rustls_pemfile::{certs, pkcs8_private_keys};
#[get("/")] #[get("/")]

View File

@ -2,9 +2,8 @@ use std::io;
use actix_governor::{Governor, GovernorConfigBuilder}; use actix_governor::{Governor, GovernorConfigBuilder};
use actix_web::{ use actix_web::{
middleware, App, HttpResponse, HttpServer, middleware,
web::{self}, web::{self},
App, HttpResponse, HttpServer,
}; };
mod rate_limit; mod rate_limit;

View File

@ -3,16 +3,16 @@
use std::{ use std::{
cell::RefCell, cell::RefCell,
cmp::min, cmp::min,
future::{ready, Ready}, future::{Ready, ready},
}; };
use actix_web::{ use actix_web::{
body::EitherBody,
dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform},
Error, HttpResponse, Error, HttpResponse,
body::EitherBody,
dev::{Service, ServiceRequest, ServiceResponse, Transform, forward_ready},
}; };
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use futures_util::{future::LocalBoxFuture, FutureExt as _, TryFutureExt as _}; use futures_util::{FutureExt as _, TryFutureExt as _, future::LocalBoxFuture};
#[doc(hidden)] #[doc(hidden)]
pub struct RateLimitService<S> { pub struct RateLimitService<S> {

View File

@ -1,11 +1,11 @@
use std::{ use std::{
future::{ready, Ready}, future::{Ready, ready},
task::{Context, Poll}, task::{Context, Poll},
}; };
use actix_web::{ use actix_web::{
dev::{Service, ServiceRequest, ServiceResponse, Transform},
Error, HttpMessage, Error, HttpMessage,
dev::{Service, ServiceRequest, ServiceResponse, Transform},
}; };
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@ -1,9 +1,8 @@
use std::io; use std::io;
use actix_web::{ use actix_web::{
middleware, App, HttpResponse, HttpServer, middleware,
web::{self, ReqData}, web::{self, ReqData},
App, HttpResponse, HttpServer,
}; };
mod add_msg; mod add_msg;

View File

@ -1,11 +1,12 @@
use std::time::Duration; use std::time::Duration;
use actix_web::{ use actix_web::{
App, Error, HttpServer,
body::MessageBody, body::MessageBody,
dev, dev,
middleware::{from_fn, Next}, middleware::{Next, from_fn},
rt::time, rt::time,
web, App, Error, HttpServer, web,
}; };
mod read_request_body; mod read_request_body;

View File

@ -1,12 +1,13 @@
use std::{ use std::{
future::{ready, Ready}, future::{Ready, ready},
rc::Rc, rc::Rc,
}; };
use actix_http::h1; use actix_http::h1;
use actix_web::{ use actix_web::{
Error,
dev::{self, Service, ServiceRequest, ServiceResponse, Transform}, dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
web, Error, web,
}; };
use futures_util::future::LocalBoxFuture; use futures_util::future::LocalBoxFuture;

View File

@ -1,15 +1,15 @@
use std::{ use std::{
future::{ready, Future, Ready}, future::{Future, Ready, ready},
marker::PhantomData, marker::PhantomData,
pin::Pin, pin::Pin,
task::{Context, Poll}, task::{Context, Poll},
}; };
use actix_web::{ use actix_web::{
Error,
body::{BodySize, MessageBody}, body::{BodySize, MessageBody},
dev::{self, Service, ServiceRequest, ServiceResponse, Transform}, dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
web::{Bytes, BytesMut}, web::{Bytes, BytesMut},
Error,
}; };
use pin_project_lite::pin_project; use pin_project_lite::pin_project;

View File

@ -1,9 +1,10 @@
use std::future::{ready, Ready}; use std::future::{Ready, ready};
use actix_web::{ use actix_web::{
Error, HttpResponse,
body::EitherBody, body::EitherBody,
dev::{self, Service, ServiceRequest, ServiceResponse, Transform}, dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
http, Error, HttpResponse, http,
}; };
use futures_util::future::LocalBoxFuture; use futures_util::future::LocalBoxFuture;

View File

@ -1,8 +1,8 @@
use std::future::{ready, Ready}; use std::future::{Ready, ready};
use actix_web::{ use actix_web::{
dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
Error, Error,
dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
}; };
use futures_util::future::LocalBoxFuture; use futures_util::future::LocalBoxFuture;

View File

@ -1,5 +1,5 @@
use actix_protobuf::{ProtoBuf, ProtoBufResponseBuilder as _}; use actix_protobuf::{ProtoBuf, ProtoBufResponseBuilder as _};
use actix_web::{middleware, web, App, HttpResponse, HttpServer, Result}; use actix_web::{App, HttpResponse, HttpServer, Result, middleware, web};
use prost::Message; use prost::Message;
#[derive(Clone, PartialEq, Eq, Message)] #[derive(Clone, PartialEq, Eq, Message)]

View File

@ -4,7 +4,7 @@
use std::{sync::mpsc, thread, time}; use std::{sync::mpsc, thread, time};
use actix_web::{dev::ServerHandle, middleware, rt, web, App, HttpRequest, HttpServer}; use actix_web::{App, HttpRequest, HttpServer, dev::ServerHandle, middleware, rt, web};
async fn index(req: HttpRequest) -> &'static str { async fn index(req: HttpRequest) -> &'static str {
log::info!("REQ: {req:?}"); log::info!("REQ: {req:?}");

View File

@ -1,6 +1,6 @@
use std::{io, sync::Arc}; use std::{io, sync::Arc};
use actix_web::{get, middleware::Logger, post, web, App, HttpResponse, HttpServer, Responder}; use actix_web::{App, HttpResponse, HttpServer, Responder, get, middleware::Logger, post, web};
use actix_web_lab::extract::Path; use actix_web_lab::extract::Path;
mod broadcast; mod broadcast;

View File

@ -1,4 +1,4 @@
use actix_web::{dev::ServerHandle, get, middleware, post, web, App, HttpResponse, HttpServer}; use actix_web::{App, HttpResponse, HttpServer, dev::ServerHandle, get, middleware, post, web};
use actix_web_lab::extract::Path; use actix_web_lab::extract::Path;
use parking_lot::Mutex; use parking_lot::Mutex;

View File

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use actix_web::{middleware, web, App, HttpServer, Responder, Result}; use actix_web::{App, HttpServer, Responder, Result, middleware, web};
use askama::Template; use askama::Template;
#[derive(Template)] #[derive(Template)]

View File

@ -1,9 +1,9 @@
use std::{ use std::{
convert::Infallible, convert::Infallible,
future::{ready, Ready}, future::{Ready, ready},
}; };
use actix_web::{dev, http::header::AcceptLanguage, FromRequest, HttpMessage as _, HttpRequest}; use actix_web::{FromRequest, HttpMessage as _, HttpRequest, dev, http::header::AcceptLanguage};
use fluent_templates::LanguageIdentifier; use fluent_templates::LanguageIdentifier;
use serde::Serialize; use serde::Serialize;

View File

@ -1,15 +1,16 @@
use std::io; use std::io;
use actix_web::{ use actix_web::{
App, HttpResponse, HttpServer, Responder, Result,
body::BoxBody, body::BoxBody,
dev::ServiceResponse, dev::ServiceResponse,
get, get,
http::{header::ContentType, StatusCode}, http::{StatusCode, header::ContentType},
middleware::{ErrorHandlerResponse, ErrorHandlers}, middleware::{ErrorHandlerResponse, ErrorHandlers},
web, App, HttpResponse, HttpServer, Responder, Result, web,
}; };
use actix_web_lab::extract::Path; use actix_web_lab::extract::Path;
use fluent_templates::{static_loader, FluentLoader, Loader as _}; use fluent_templates::{FluentLoader, Loader as _, static_loader};
use handlebars::{DirectorySourceOptions, Handlebars}; use handlebars::{DirectorySourceOptions, Handlebars};
use serde_json::json; use serde_json::json;

View File

@ -1,12 +1,13 @@
use std::io; use std::io;
use actix_web::{ use actix_web::{
App, HttpResponse, HttpServer, Responder, Result,
body::BoxBody, body::BoxBody,
dev::ServiceResponse, dev::ServiceResponse,
get, get,
http::{header::ContentType, StatusCode}, http::{StatusCode, header::ContentType},
middleware::{ErrorHandlerResponse, ErrorHandlers}, middleware::{ErrorHandlerResponse, ErrorHandlers},
web, App, HttpResponse, HttpServer, Responder, Result, web,
}; };
use handlebars::{DirectorySourceOptions, Handlebars}; use handlebars::{DirectorySourceOptions, Handlebars};
use serde_json::json; use serde_json::json;

View File

@ -1,7 +1,7 @@
use actix_web::{ use actix_web::{
error, get, App, HttpServer, Responder, error, get,
middleware::{Compress, Logger}, middleware::{Compress, Logger},
web, App, HttpServer, Responder, web,
}; };
use sailfish::TemplateOnce; use sailfish::TemplateOnce;

View File

@ -1,12 +1,13 @@
use std::collections::HashMap; use std::collections::HashMap;
use actix_web::{ use actix_web::{
App, Error, HttpResponse, HttpServer, Responder, Result,
body::BoxBody, body::BoxBody,
dev::ServiceResponse, dev::ServiceResponse,
error, error,
http::{header::ContentType, StatusCode}, http::{StatusCode, header::ContentType},
middleware::{self, ErrorHandlerResponse, ErrorHandlers}, middleware::{self, ErrorHandlerResponse, ErrorHandlers},
web, App, Error, HttpResponse, HttpServer, Responder, Result, web,
}; };
use tera::Tera; use tera::Tera;

View File

@ -1,13 +1,14 @@
use std::collections::HashMap; use std::collections::HashMap;
use actix_web::{ use actix_web::{
App, Error, HttpResponse, HttpServer, Result,
body::BoxBody, body::BoxBody,
dev::ServiceResponse, dev::ServiceResponse,
error, error,
http::{header::ContentType, StatusCode}, http::{StatusCode, header::ContentType},
middleware, middleware,
middleware::{ErrorHandlerResponse, ErrorHandlers}, middleware::{ErrorHandlerResponse, ErrorHandlers},
web, App, Error, HttpResponse, HttpServer, Result, web,
}; };
use serde_json::json; use serde_json::json;
use tinytemplate::TinyTemplate; use tinytemplate::TinyTemplate;

View File

@ -1,7 +1,7 @@
use std::collections::HashMap; use std::collections::HashMap;
use actix_web::{ use actix_web::{
get, middleware::Logger, web, App, Error, HttpResponse, HttpServer, ResponseError, App, Error, HttpResponse, HttpServer, ResponseError, get, middleware::Logger, web,
}; };
use derive_more::Display; use derive_more::Display;
use yarte::{auto, ywrite_min}; use yarte::{auto, ywrite_min};

View File

@ -2,11 +2,11 @@ use std::{io, time::Duration};
use opentelemetry::KeyValue; use opentelemetry::KeyValue;
use opentelemetry_otlp::WithExportConfig as _; use opentelemetry_otlp::WithExportConfig as _;
use opentelemetry_sdk::{runtime, trace::Tracer, Resource}; use opentelemetry_sdk::{Resource, runtime, trace::Tracer};
use tonic::metadata::MetadataMap; use tonic::metadata::MetadataMap;
use tracing::level_filters::LevelFilter; use tracing::level_filters::LevelFilter;
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _, EnvFilter}; use tracing_subscriber::{EnvFilter, layer::SubscriberExt as _, util::SubscriberInitExt as _};
pub(crate) fn init() { pub(crate) fn init() {
let app_name = "actix-web-mainmatter-telemetry-workshop-capstone"; let app_name = "actix-web-mainmatter-telemetry-workshop-capstone";

View File

@ -1,6 +1,6 @@
use std::io; use std::io;
use actix_web::{middleware::from_fn, web::ThinData, App, HttpServer}; use actix_web::{App, HttpServer, middleware::from_fn, web::ThinData};
use tracing_actix_web::TracingLogger; use tracing_actix_web::TracingLogger;
mod logging; mod logging;

View File

@ -1,11 +1,11 @@
use std::time::Instant; use std::time::Instant;
use actix_web::{ use actix_web::{
HttpMessage as _,
body::MessageBody, body::MessageBody,
dev::{ServiceRequest, ServiceResponse}, dev::{ServiceRequest, ServiceResponse},
http::header::{HeaderName, HeaderValue}, http::header::{HeaderName, HeaderValue},
middleware::Next, middleware::Next,
HttpMessage as _,
}; };
use tracing_actix_web::RequestId; use tracing_actix_web::RequestId;

View File

@ -1,6 +1,6 @@
use std::time::Duration; use std::time::Duration;
use actix_web::{get, web::ThinData, HttpResponse, Responder}; use actix_web::{HttpResponse, Responder, get, web::ThinData};
use metrics_exporter_prometheus::PrometheusHandle; use metrics_exporter_prometheus::PrometheusHandle;
#[get("/hello")] #[get("/hello")]

View File

@ -1,4 +1,4 @@
use actix_web::{middleware, web, App, HttpRequest, HttpServer}; use actix_web::{App, HttpRequest, HttpServer, middleware, web};
async fn index(_req: HttpRequest) -> &'static str { async fn index(_req: HttpRequest) -> &'static str {
"Hello world!" "Hello world!"

View File

@ -1,5 +1,5 @@
use actix::prelude::*; use actix::prelude::*;
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer}; use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, middleware, web};
use actix_web_actors::ws; use actix_web_actors::ws;
async fn ws_index(r: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> { async fn ws_index(r: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {

View File

@ -5,7 +5,7 @@
use std::io; use std::io;
use actix_files::NamedFile; use actix_files::NamedFile;
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder}; use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, Responder, middleware, web};
use tokio::{ use tokio::{
task::{spawn, spawn_local}, task::{spawn, spawn_local},
try_join, try_join,

View File

@ -4,8 +4,8 @@ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
io, io,
sync::{ sync::{
atomic::{AtomicUsize, Ordering},
Arc, Arc,
atomic::{AtomicUsize, Ordering},
}, },
}; };

View File

@ -1,5 +1,5 @@
use actix_files::{Files, NamedFile}; use actix_files::{Files, NamedFile};
use actix_web::{middleware::Logger, web, App, Error, HttpRequest, HttpServer, Responder}; use actix_web::{App, Error, HttpRequest, HttpServer, Responder, middleware::Logger, web};
use actix_web_actors::ws; use actix_web_actors::ws;
mod message; mod message;

View File

@ -16,20 +16,22 @@ async fn main() {
let mut cmd_rx = UnboundedReceiverStream::new(cmd_rx); let mut cmd_rx = UnboundedReceiverStream::new(cmd_rx);
// run blocking terminal input reader on separate thread // run blocking terminal input reader on separate thread
let input_thread = thread::spawn(move || loop { let input_thread = thread::spawn(move || {
let mut cmd = String::with_capacity(32); loop {
let mut cmd = String::with_capacity(32);
if io::stdin().read_line(&mut cmd).is_err() { if io::stdin().read_line(&mut cmd).is_err() {
log::error!("error reading line"); log::error!("error reading line");
return; return;
}
if cmd.trim() == "/exit" {
println!("exiting input loop");
return;
}
cmd_tx.send(cmd).unwrap();
} }
if cmd.trim() == "/exit" {
println!("exiting input loop");
return;
}
cmd_tx.send(cmd).unwrap();
}); });
let io = TcpStream::connect(("127.0.0.1", 12345)).await.unwrap(); let io = TcpStream::connect(("127.0.0.1", 12345)).await.unwrap();

View File

@ -2,7 +2,7 @@ use std::time::{Duration, Instant};
use actix::prelude::*; use actix::prelude::*;
use actix_files::NamedFile; use actix_files::NamedFile;
use actix_web::{middleware::Logger, web, App, Error, HttpRequest, HttpServer, Responder}; use actix_web::{App, Error, HttpRequest, HttpServer, Responder, middleware::Logger, web};
use actix_web_actors::ws; use actix_web_actors::ws;
mod codec; mod codec;

View File

@ -9,7 +9,7 @@ use std::{
use actix::{prelude::*, spawn}; use actix::{prelude::*, spawn};
use tokio::{ use tokio::{
io::{split, WriteHalf}, io::{WriteHalf, split},
net::{TcpListener, TcpStream}, net::{TcpListener, TcpStream},
}; };
use tokio_util::codec::FramedRead; use tokio_util::codec::FramedRead;

View File

@ -1,7 +1,7 @@
use std::{ use std::{
sync::{ sync::{
atomic::{AtomicUsize, Ordering},
Arc, Arc,
atomic::{AtomicUsize, Ordering},
}, },
time::Instant, time::Instant,
}; };
@ -9,7 +9,7 @@ use std::{
use actix::*; use actix::*;
use actix_files::{Files, NamedFile}; use actix_files::{Files, NamedFile};
use actix_web::{ use actix_web::{
middleware::Logger, web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder, App, Error, HttpRequest, HttpResponse, HttpServer, Responder, middleware::Logger, web,
}; };
use actix_web_actors::ws; use actix_web_actors::ws;

View File

@ -5,8 +5,8 @@
use std::{ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
sync::{ sync::{
atomic::{AtomicUsize, Ordering},
Arc, Arc,
atomic::{AtomicUsize, Ordering},
}, },
}; };

View File

@ -18,15 +18,17 @@ async fn main() {
let mut cmd_rx = UnboundedReceiverStream::new(cmd_rx); let mut cmd_rx = UnboundedReceiverStream::new(cmd_rx);
// run blocking terminal input reader on separate thread // run blocking terminal input reader on separate thread
let input_thread = thread::spawn(move || loop { let input_thread = thread::spawn(move || {
let mut cmd = String::with_capacity(32); loop {
let mut cmd = String::with_capacity(32);
if io::stdin().read_line(&mut cmd).is_err() { if io::stdin().read_line(&mut cmd).is_err() {
log::error!("error reading line"); log::error!("error reading line");
return; return;
}
cmd_tx.send(cmd).unwrap();
} }
cmd_tx.send(cmd).unwrap();
}); });
let (res, mut ws) = awc::Client::new() let (res, mut ws) = awc::Client::new()

View File

@ -3,8 +3,8 @@ use std::time::{Duration, Instant};
use actix_web::web; use actix_web::web;
use actix_ws::Message; use actix_ws::Message;
use futures_util::{ use futures_util::{
future::{self, Either},
StreamExt as _, StreamExt as _,
future::{self, Either},
}; };
use tokio::{pin, select, sync::broadcast, time::interval}; use tokio::{pin, select, sync::broadcast, time::interval};

View File

@ -6,7 +6,7 @@ use std::io;
use actix_files::NamedFile; use actix_files::NamedFile;
use actix_web::{ use actix_web::{
middleware, rt, web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder, App, Error, HttpRequest, HttpResponse, HttpServer, Responder, middleware, rt, web,
}; };
use tokio::sync::broadcast; use tokio::sync::broadcast;

View File

@ -3,7 +3,7 @@
//! Open `http://localhost:8080/` in browser to test. //! Open `http://localhost:8080/` in browser to test.
use actix_files::NamedFile; use actix_files::NamedFile;
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder}; use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, Responder, middleware, web};
use ractor::Actor; use ractor::Actor;
mod server; mod server;