mirror of
https://github.com/actix/examples
synced 2025-03-28 05:48:40 +01:00
chore: fmt
This commit is contained in:
parent
a7527d72f3
commit
04f8cba71b
1105
Cargo.lock
generated
1105
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
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};
|
||||
|
||||
/// simple handle
|
||||
|
@ -1,10 +1,11 @@
|
||||
use actix_identity::{Identity, IdentityMiddleware};
|
||||
use actix_session::{config::PersistentSession, storage::CookieSessionStore, SessionMiddleware};
|
||||
use actix_session::{SessionMiddleware, config::PersistentSession, storage::CookieSessionStore};
|
||||
use actix_web::{
|
||||
cookie::{time::Duration, Key},
|
||||
App, HttpMessage as _, HttpRequest, HttpServer, Responder,
|
||||
cookie::{Key, time::Duration},
|
||||
error,
|
||||
http::StatusCode,
|
||||
middleware, web, App, HttpMessage as _, HttpRequest, HttpServer, Responder,
|
||||
middleware, web,
|
||||
};
|
||||
|
||||
const ONE_MINUTE: Duration = Duration::minutes(1);
|
||||
|
@ -6,12 +6,13 @@
|
||||
//! [User guide](https://actix.rs/docs/middleware/#user-sessions)
|
||||
|
||||
use actix_session::{
|
||||
config::PersistentSession, storage::CookieSessionStore, Session, SessionMiddleware,
|
||||
Session, SessionMiddleware, config::PersistentSession, storage::CookieSessionStore,
|
||||
};
|
||||
use actix_web::{
|
||||
App, HttpRequest, HttpServer, Result,
|
||||
cookie::{self, Key},
|
||||
middleware::Logger,
|
||||
web, App, HttpRequest, HttpServer, Result,
|
||||
web,
|
||||
};
|
||||
|
||||
/// simple index handler with session
|
||||
|
@ -4,11 +4,10 @@
|
||||
//! 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.
|
||||
|
||||
use actix_session::{storage::RedisSessionStore, Session, SessionMiddleware};
|
||||
use actix_session::{Session, SessionMiddleware, storage::RedisSessionStore};
|
||||
use actix_web::{
|
||||
middleware, web,
|
||||
App, HttpResponse, HttpServer, Result, middleware, web,
|
||||
web::{get, post, resource},
|
||||
App, HttpResponse, HttpServer, Result,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::future::{ready, Ready};
|
||||
use std::future::{Ready, ready};
|
||||
|
||||
use actix_identity::Identity;
|
||||
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 serde::Deserialize;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_web::{HttpResponse, web};
|
||||
use diesel::prelude::*;
|
||||
use serde::Deserialize;
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
extern crate diesel;
|
||||
|
||||
use actix_identity::IdentityMiddleware;
|
||||
use actix_session::{config::PersistentSession, storage::CookieSessionStore, SessionMiddleware};
|
||||
use actix_web::{cookie::Key, middleware, web, App, HttpServer};
|
||||
use actix_session::{SessionMiddleware, config::PersistentSession, storage::CookieSessionStore};
|
||||
use actix_web::{App, HttpServer, cookie::Key, middleware, web};
|
||||
use diesel::{prelude::*, r2d2};
|
||||
use time::Duration;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![allow(clippy::extra_unused_lifetimes)]
|
||||
|
||||
use chrono::{NaiveDateTime, TimeDelta, Utc};
|
||||
use diesel::{r2d2::ConnectionManager, PgConnection};
|
||||
use diesel::{PgConnection, r2d2::ConnectionManager};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_web::{HttpResponse, web};
|
||||
use diesel::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
@ -3,7 +3,7 @@ use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use actix_web::{web::Data, App, HttpServer};
|
||||
use actix_web::{App, HttpServer, web::Data};
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
mod ephemeral_jobs;
|
||||
|
@ -1,14 +1,13 @@
|
||||
use actix_web::{
|
||||
error, get, post,
|
||||
HttpResponse, Responder, error, get, post,
|
||||
web::{self, Data},
|
||||
HttpResponse, Responder,
|
||||
};
|
||||
use apalis::prelude::*;
|
||||
use apalis_redis::RedisStorage;
|
||||
use chrono::{TimeDelta, Utc};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{persistent_jobs::Email, ItemCache};
|
||||
use crate::{ItemCache, persistent_jobs::Email};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct CacheInsert {
|
||||
|
@ -1,14 +1,14 @@
|
||||
use std::{convert::Infallible, io};
|
||||
|
||||
use actix_files::{Files, NamedFile};
|
||||
use actix_session::{storage::CookieSessionStore, Session, SessionMiddleware};
|
||||
use actix_session::{Session, SessionMiddleware, storage::CookieSessionStore};
|
||||
use actix_web::{
|
||||
error, get,
|
||||
App, Either, HttpRequest, HttpResponse, HttpServer, Responder, Result, error, get,
|
||||
http::{
|
||||
header::{self, ContentType},
|
||||
Method, StatusCode,
|
||||
header::{self, ContentType},
|
||||
},
|
||||
middleware, web, App, Either, HttpRequest, HttpResponse, HttpServer, Responder, Result,
|
||||
middleware, web,
|
||||
};
|
||||
use actix_web_lab::extract::Path;
|
||||
use async_stream::stream;
|
||||
|
@ -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 rand::{
|
||||
distr::{Distribution, StandardUniform},
|
||||
Rng,
|
||||
distr::{Distribution, StandardUniform},
|
||||
};
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
|
@ -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 {
|
||||
println!("REQ: {req:?}");
|
||||
@ -25,7 +25,7 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
#[cfg(test)]
|
||||
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::*;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{web, Error, HttpResponse};
|
||||
use actix_web::{Error, HttpResponse, web};
|
||||
|
||||
use crate::common::{Part, Product};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{web, Error, HttpResponse};
|
||||
use actix_web::{Error, HttpResponse, web};
|
||||
|
||||
use crate::common::{Part, Product};
|
||||
|
||||
@ -21,9 +21,10 @@ pub async fn remove_product(_id: web::Path<String>) -> Result<HttpResponse, Erro
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_web::{
|
||||
App,
|
||||
dev::Service,
|
||||
http::{header, StatusCode},
|
||||
test, App,
|
||||
http::{StatusCode, header},
|
||||
test,
|
||||
};
|
||||
|
||||
use crate::app_config::config_app;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{middleware, App, HttpServer};
|
||||
use actix_web::{App, HttpServer, middleware};
|
||||
use nested_routing::app_config::config_app;
|
||||
|
||||
#[actix_web::main]
|
||||
|
@ -22,15 +22,14 @@ use std::{
|
||||
cell::Cell,
|
||||
io,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Mutex,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
};
|
||||
|
||||
use actix_web::{
|
||||
middleware,
|
||||
App, HttpRequest, HttpResponse, HttpServer, middleware,
|
||||
web::{self, Data},
|
||||
App, HttpRequest, HttpResponse, HttpServer,
|
||||
};
|
||||
|
||||
/// simple handle
|
||||
|
@ -1,5 +1,5 @@
|
||||
use actix_files::Files;
|
||||
use actix_web::{middleware::Logger, App, HttpServer};
|
||||
use actix_web::{App, HttpServer, middleware::Logger};
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use actix_files::NamedFile;
|
||||
use actix_session::Session;
|
||||
use actix_web::{
|
||||
dev, error, http::StatusCode, middleware::ErrorHandlerResponse, web, Error, HttpResponse,
|
||||
Responder, Result,
|
||||
Error, HttpResponse, Responder, Result, dev, error, http::StatusCode,
|
||||
middleware::ErrorHandlerResponse, web,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use sqlx::SqlitePool;
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::{env, io};
|
||||
|
||||
use actix_files::Files;
|
||||
use actix_session::{storage::CookieSessionStore, SessionMiddleware};
|
||||
use actix_session::{SessionMiddleware, storage::CookieSessionStore};
|
||||
use actix_web::{
|
||||
http,
|
||||
App, HttpServer, http,
|
||||
middleware::{ErrorHandlers, Logger},
|
||||
web, App, HttpServer,
|
||||
web,
|
||||
};
|
||||
use dotenvy::dotenv;
|
||||
use tera::Tera;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::io;
|
||||
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{http::header, middleware::Logger, App, HttpServer};
|
||||
use actix_web::{App, HttpServer, http::header, middleware::Logger};
|
||||
|
||||
mod user;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{web, App, HttpResponse, HttpServer};
|
||||
use actix_web::{App, HttpResponse, HttpServer, web};
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
|
@ -6,7 +6,7 @@
|
||||
#[macro_use]
|
||||
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 uuid::Uuid;
|
||||
|
||||
|
@ -4,9 +4,9 @@ mod model;
|
||||
#[cfg(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 mongodb::{bson::doc, options::IndexOptions, Client, Collection, IndexModel};
|
||||
use mongodb::{Client, Collection, IndexModel, bson::doc, options::IndexOptions};
|
||||
|
||||
const DB_NAME: &str = "myApp";
|
||||
const COLL_NAME: &str = "users";
|
||||
|
@ -1,5 +1,5 @@
|
||||
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,
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{env, io};
|
||||
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use actix_web::{App, HttpServer, web};
|
||||
|
||||
mod models;
|
||||
mod persistence;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_web::{get, post, web, HttpResponse, Responder};
|
||||
use actix_web::{HttpResponse, Responder, get, post, web};
|
||||
|
||||
use crate::{
|
||||
models::{BankData, BranchData, CustomerData, TellerData},
|
||||
|
@ -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 deadpool_postgres::{Client, Pool};
|
||||
use dotenvy::dotenv;
|
||||
|
@ -1,6 +1,6 @@
|
||||
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;
|
||||
|
||||
async fn get_from_cache(redis: web::Data<redis::Client>) -> actix_web::Result<impl Responder> {
|
||||
|
@ -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("/")]
|
||||
async fn index() -> impl Responder {
|
||||
|
@ -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};
|
||||
|
||||
struct AppState {
|
||||
@ -74,8 +74,8 @@ mod tests {
|
||||
body::to_bytes,
|
||||
dev::ServiceResponse,
|
||||
http::{
|
||||
header::{HeaderValue, CONTENT_TYPE},
|
||||
StatusCode,
|
||||
header::{CONTENT_TYPE, HeaderValue},
|
||||
},
|
||||
test::{self, TestRequest},
|
||||
web::{Bytes, Form},
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::env;
|
||||
|
||||
use aws_config::SdkConfig as AwsConfig;
|
||||
use aws_sdk_s3::{primitives::ByteStream, Client as S3Client};
|
||||
use futures_util::{stream, StreamExt as _};
|
||||
use aws_sdk_s3::{Client as S3Client, primitives::ByteStream};
|
||||
use futures_util::{StreamExt as _, stream};
|
||||
use tokio::{fs, io::AsyncReadExt as _};
|
||||
|
||||
use crate::{TempFile, UploadedFile};
|
||||
|
@ -1,14 +1,14 @@
|
||||
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::{
|
||||
body::SizedStream, delete, error, get, http::Method, middleware::Logger, post, route, web, App,
|
||||
Error, HttpResponse, HttpServer, Responder,
|
||||
App, Error, HttpResponse, HttpServer, Responder, body::SizedStream, delete, error, get,
|
||||
http::Method, middleware::Logger, post, route, web,
|
||||
};
|
||||
use actix_web_lab::extract::Path;
|
||||
use aws_config::{meta::region::RegionProviderChain, BehaviorVersion};
|
||||
use aws_config::{BehaviorVersion, meta::region::RegionProviderChain};
|
||||
use dotenvy::dotenv;
|
||||
use futures_util::{stream, StreamExt as _};
|
||||
use futures_util::{StreamExt as _, stream};
|
||||
use serde_json::json;
|
||||
use tokio_util::io::ReaderStream;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
use std::io::Write;
|
||||
|
||||
use actix_multipart::{
|
||||
form::{
|
||||
tempfile::{TempFile, TempFileConfig},
|
||||
MultipartForm,
|
||||
},
|
||||
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 uuid::Uuid;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
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::{
|
||||
http::{playground_source, GraphQLPlaygroundConfig},
|
||||
EmptyMutation, EmptySubscription, Schema,
|
||||
http::{GraphQLPlaygroundConfig, playground_source},
|
||||
};
|
||||
use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use async_graphql::{
|
||||
connection::{query, Connection, Edge},
|
||||
Context, Enum, Error, Interface, Object, OutputType, Result,
|
||||
connection::{Connection, Edge, query},
|
||||
};
|
||||
|
||||
use super::{StarWars, StarWarsChar};
|
||||
|
@ -1,6 +1,6 @@
|
||||
use r2d2_mysql::{
|
||||
mysql::{Opts, OptsBuilder},
|
||||
MySqlConnectionManager,
|
||||
mysql::{Opts, OptsBuilder},
|
||||
};
|
||||
|
||||
pub type Pool = r2d2::Pool<MySqlConnectionManager>;
|
||||
|
@ -1,9 +1,9 @@
|
||||
use actix_web::{get, route, web, Error, HttpResponse, Responder};
|
||||
use juniper::http::{graphiql::graphiql_source, GraphQLRequest};
|
||||
use actix_web::{Error, HttpResponse, Responder, get, route, web};
|
||||
use juniper::http::{GraphQLRequest, graphiql::graphiql_source};
|
||||
|
||||
use crate::{
|
||||
db::Pool,
|
||||
schemas::root::{create_schema, Context, Schema},
|
||||
schemas::root::{Context, Schema, create_schema},
|
||||
};
|
||||
|
||||
/// GraphQL endpoint
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 handlers;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
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::{
|
||||
product::{Product, ProductInput},
|
||||
|
@ -1,5 +1,5 @@
|
||||
use juniper::{graphql_object, GraphQLInputObject};
|
||||
use mysql::{from_row, params, prelude::*, Row};
|
||||
use juniper::{GraphQLInputObject, graphql_object};
|
||||
use mysql::{Row, from_row, params, prelude::*};
|
||||
|
||||
use crate::schemas::{product::Product, root::Context};
|
||||
|
||||
|
@ -6,15 +6,14 @@ use std::{io, sync::Arc};
|
||||
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{
|
||||
get, middleware, route,
|
||||
App, HttpResponse, HttpServer, Responder, get, middleware, route,
|
||||
web::{self, Data},
|
||||
App, HttpResponse, HttpServer, Responder,
|
||||
};
|
||||
use juniper::http::{graphiql::graphiql_source, GraphQLRequest};
|
||||
use juniper::http::{GraphQLRequest, graphiql::graphiql_source};
|
||||
|
||||
mod schema;
|
||||
|
||||
use crate::schema::{create_schema, Schema};
|
||||
use crate::schema::{Schema, create_schema};
|
||||
|
||||
/// GraphiQL playground UI
|
||||
#[get("/graphiql")]
|
||||
|
@ -1,10 +1,11 @@
|
||||
use actix_web::{
|
||||
App, Error, HttpServer, Responder,
|
||||
body::MessageBody,
|
||||
dev::{ServiceFactory, ServiceRequest, ServiceResponse},
|
||||
get,
|
||||
guard::{Guard, GuardContext},
|
||||
middleware::DefaultHeaders,
|
||||
web, App, Error, HttpServer, Responder,
|
||||
web,
|
||||
};
|
||||
|
||||
mod v1 {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{io, net::ToSocketAddrs as _};
|
||||
|
||||
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 clap::Parser;
|
||||
|
@ -1,8 +1,8 @@
|
||||
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_web::{rt, web, App, HttpRequest, HttpServer, Responder};
|
||||
use actix_web::{App, HttpRequest, HttpServer, Responder, rt, web};
|
||||
use eyre::eyre;
|
||||
use rustls::pki_types::{PrivateKeyDer, PrivatePkcs8KeyDer};
|
||||
use tokio::fs;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{sync::Arc, time::Instant};
|
||||
|
||||
use actix_web::{get, middleware, web::Data, App, HttpResponse, HttpServer};
|
||||
use awc::{http::header, Client, Connector};
|
||||
use actix_web::{App, HttpResponse, HttpServer, get, middleware, web::Data};
|
||||
use awc::{Client, Connector, http::header};
|
||||
use rustls::{ClientConfig, RootCertStore};
|
||||
|
||||
const MAP_URL: &str =
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::{fs::File, io::BufReader, path::Path};
|
||||
|
||||
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 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 tokio::sync::mpsc;
|
||||
|
||||
|
@ -3,7 +3,7 @@ use std::{
|
||||
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::{
|
||||
pkey::{PKey, Private},
|
||||
ssl::{SslAcceptor, SslMethod},
|
||||
|
@ -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_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 rustls::{
|
||||
RootCertStore, ServerConfig,
|
||||
pki_types::{CertificateDer, PrivateKeyDer},
|
||||
server::WebPkiClientVerifier,
|
||||
RootCertStore, ServerConfig,
|
||||
};
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
|
||||
|
@ -2,10 +2,10 @@ use std::{fs::File, io::BufReader};
|
||||
|
||||
use actix_files::Files;
|
||||
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 rustls::{pki_types::PrivateKeyDer, ServerConfig};
|
||||
use rustls::{ServerConfig, pki_types::PrivateKeyDer};
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
|
||||
/// simple handle
|
||||
|
@ -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;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
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;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
|
@ -15,9 +15,9 @@
|
||||
use std::io;
|
||||
|
||||
use actix_web::{
|
||||
App, Error, HttpResponse, HttpServer,
|
||||
error::ErrorBadRequest,
|
||||
web::{self, BytesMut},
|
||||
App, Error, HttpResponse, HttpServer,
|
||||
};
|
||||
use awc::Client;
|
||||
use futures_util::StreamExt as _;
|
||||
|
@ -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};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
@ -1,11 +1,11 @@
|
||||
use actix_web::{
|
||||
App, Error, HttpServer, Responder,
|
||||
body::{self, MessageBody},
|
||||
dev::{self, ServiceResponse},
|
||||
middleware::{from_fn, Logger, Next},
|
||||
middleware::{Logger, Next, from_fn},
|
||||
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 serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
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 rustls::{pki_types::PrivateKeyDer, ServerConfig};
|
||||
use rustls::{ServerConfig, pki_types::PrivateKeyDer};
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
|
||||
#[get("/")]
|
||||
|
@ -2,9 +2,8 @@ use std::io;
|
||||
|
||||
use actix_governor::{Governor, GovernorConfigBuilder};
|
||||
use actix_web::{
|
||||
middleware,
|
||||
App, HttpResponse, HttpServer, middleware,
|
||||
web::{self},
|
||||
App, HttpResponse, HttpServer,
|
||||
};
|
||||
|
||||
mod rate_limit;
|
||||
|
@ -3,16 +3,16 @@
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
cmp::min,
|
||||
future::{ready, Ready},
|
||||
future::{Ready, ready},
|
||||
};
|
||||
|
||||
use actix_web::{
|
||||
body::EitherBody,
|
||||
dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
Error, HttpResponse,
|
||||
body::EitherBody,
|
||||
dev::{Service, ServiceRequest, ServiceResponse, Transform, forward_ready},
|
||||
};
|
||||
use chrono::{DateTime, Utc};
|
||||
use futures_util::{future::LocalBoxFuture, FutureExt as _, TryFutureExt as _};
|
||||
use futures_util::{FutureExt as _, TryFutureExt as _, future::LocalBoxFuture};
|
||||
|
||||
#[doc(hidden)]
|
||||
pub struct RateLimitService<S> {
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::{
|
||||
future::{ready, Ready},
|
||||
future::{Ready, ready},
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use actix_web::{
|
||||
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
||||
Error, HttpMessage,
|
||||
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -1,9 +1,8 @@
|
||||
use std::io;
|
||||
|
||||
use actix_web::{
|
||||
middleware,
|
||||
App, HttpResponse, HttpServer, middleware,
|
||||
web::{self, ReqData},
|
||||
App, HttpResponse, HttpServer,
|
||||
};
|
||||
|
||||
mod add_msg;
|
||||
|
@ -1,11 +1,12 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_web::{
|
||||
App, Error, HttpServer,
|
||||
body::MessageBody,
|
||||
dev,
|
||||
middleware::{from_fn, Next},
|
||||
middleware::{Next, from_fn},
|
||||
rt::time,
|
||||
web, App, Error, HttpServer,
|
||||
web,
|
||||
};
|
||||
|
||||
mod read_request_body;
|
||||
|
@ -1,12 +1,13 @@
|
||||
use std::{
|
||||
future::{ready, Ready},
|
||||
future::{Ready, ready},
|
||||
rc::Rc,
|
||||
};
|
||||
|
||||
use actix_http::h1;
|
||||
use actix_web::{
|
||||
Error,
|
||||
dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
web, Error,
|
||||
web,
|
||||
};
|
||||
use futures_util::future::LocalBoxFuture;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
use std::{
|
||||
future::{ready, Future, Ready},
|
||||
future::{Future, Ready, ready},
|
||||
marker::PhantomData,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use actix_web::{
|
||||
Error,
|
||||
body::{BodySize, MessageBody},
|
||||
dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
web::{Bytes, BytesMut},
|
||||
Error,
|
||||
};
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
use std::future::{ready, Ready};
|
||||
use std::future::{Ready, ready};
|
||||
|
||||
use actix_web::{
|
||||
Error, HttpResponse,
|
||||
body::EitherBody,
|
||||
dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
http, Error, HttpResponse,
|
||||
http,
|
||||
};
|
||||
use futures_util::future::LocalBoxFuture;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
use std::future::{ready, Ready};
|
||||
use std::future::{Ready, ready};
|
||||
|
||||
use actix_web::{
|
||||
dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
Error,
|
||||
dev::{self, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
};
|
||||
use futures_util::future::LocalBoxFuture;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
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;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Message)]
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
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 {
|
||||
log::info!("REQ: {req:?}");
|
||||
|
@ -1,6 +1,6 @@
|
||||
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;
|
||||
|
||||
mod broadcast;
|
||||
|
@ -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 parking_lot::Mutex;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
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;
|
||||
|
||||
#[derive(Template)]
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::{
|
||||
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 serde::Serialize;
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
use std::io;
|
||||
|
||||
use actix_web::{
|
||||
App, HttpResponse, HttpServer, Responder, Result,
|
||||
body::BoxBody,
|
||||
dev::ServiceResponse,
|
||||
get,
|
||||
http::{header::ContentType, StatusCode},
|
||||
http::{StatusCode, header::ContentType},
|
||||
middleware::{ErrorHandlerResponse, ErrorHandlers},
|
||||
web, App, HttpResponse, HttpServer, Responder, Result,
|
||||
web,
|
||||
};
|
||||
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 serde_json::json;
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
use std::io;
|
||||
|
||||
use actix_web::{
|
||||
App, HttpResponse, HttpServer, Responder, Result,
|
||||
body::BoxBody,
|
||||
dev::ServiceResponse,
|
||||
get,
|
||||
http::{header::ContentType, StatusCode},
|
||||
http::{StatusCode, header::ContentType},
|
||||
middleware::{ErrorHandlerResponse, ErrorHandlers},
|
||||
web, App, HttpResponse, HttpServer, Responder, Result,
|
||||
web,
|
||||
};
|
||||
use handlebars::{DirectorySourceOptions, Handlebars};
|
||||
use serde_json::json;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use actix_web::{
|
||||
error, get,
|
||||
App, HttpServer, Responder, error, get,
|
||||
middleware::{Compress, Logger},
|
||||
web, App, HttpServer, Responder,
|
||||
web,
|
||||
};
|
||||
use sailfish::TemplateOnce;
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use actix_web::{
|
||||
App, Error, HttpResponse, HttpServer, Responder, Result,
|
||||
body::BoxBody,
|
||||
dev::ServiceResponse,
|
||||
error,
|
||||
http::{header::ContentType, StatusCode},
|
||||
http::{StatusCode, header::ContentType},
|
||||
middleware::{self, ErrorHandlerResponse, ErrorHandlers},
|
||||
web, App, Error, HttpResponse, HttpServer, Responder, Result,
|
||||
web,
|
||||
};
|
||||
use tera::Tera;
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use actix_web::{
|
||||
App, Error, HttpResponse, HttpServer, Result,
|
||||
body::BoxBody,
|
||||
dev::ServiceResponse,
|
||||
error,
|
||||
http::{header::ContentType, StatusCode},
|
||||
http::{StatusCode, header::ContentType},
|
||||
middleware,
|
||||
middleware::{ErrorHandlerResponse, ErrorHandlers},
|
||||
web, App, Error, HttpResponse, HttpServer, Result,
|
||||
web,
|
||||
};
|
||||
use serde_json::json;
|
||||
use tinytemplate::TinyTemplate;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
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 yarte::{auto, ywrite_min};
|
||||
|
@ -2,11 +2,11 @@ use std::{io, time::Duration};
|
||||
|
||||
use opentelemetry::KeyValue;
|
||||
use opentelemetry_otlp::WithExportConfig as _;
|
||||
use opentelemetry_sdk::{runtime, trace::Tracer, Resource};
|
||||
use opentelemetry_sdk::{Resource, runtime, trace::Tracer};
|
||||
use tonic::metadata::MetadataMap;
|
||||
use tracing::level_filters::LevelFilter;
|
||||
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() {
|
||||
let app_name = "actix-web-mainmatter-telemetry-workshop-capstone";
|
||||
|
@ -1,6 +1,6 @@
|
||||
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;
|
||||
|
||||
mod logging;
|
||||
|
@ -1,11 +1,11 @@
|
||||
use std::time::Instant;
|
||||
|
||||
use actix_web::{
|
||||
HttpMessage as _,
|
||||
body::MessageBody,
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
http::header::{HeaderName, HeaderValue},
|
||||
middleware::Next,
|
||||
HttpMessage as _,
|
||||
};
|
||||
use tracing_actix_web::RequestId;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
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;
|
||||
|
||||
#[get("/hello")]
|
||||
|
@ -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 {
|
||||
"Hello world!"
|
||||
|
@ -1,5 +1,5 @@
|
||||
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;
|
||||
|
||||
async fn ws_index(r: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||
|
@ -5,7 +5,7 @@
|
||||
use std::io;
|
||||
|
||||
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::{
|
||||
task::{spawn, spawn_local},
|
||||
try_join,
|
||||
|
@ -4,8 +4,8 @@ use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
io,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
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;
|
||||
|
||||
mod message;
|
||||
|
@ -16,20 +16,22 @@ async fn main() {
|
||||
let mut cmd_rx = UnboundedReceiverStream::new(cmd_rx);
|
||||
|
||||
// run blocking terminal input reader on separate thread
|
||||
let input_thread = thread::spawn(move || loop {
|
||||
let mut cmd = String::with_capacity(32);
|
||||
let input_thread = thread::spawn(move || {
|
||||
loop {
|
||||
let mut cmd = String::with_capacity(32);
|
||||
|
||||
if io::stdin().read_line(&mut cmd).is_err() {
|
||||
log::error!("error reading line");
|
||||
return;
|
||||
if io::stdin().read_line(&mut cmd).is_err() {
|
||||
log::error!("error reading line");
|
||||
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();
|
||||
|
@ -2,7 +2,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use actix::prelude::*;
|
||||
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;
|
||||
|
||||
mod codec;
|
||||
|
@ -9,7 +9,7 @@ use std::{
|
||||
|
||||
use actix::{prelude::*, spawn};
|
||||
use tokio::{
|
||||
io::{split, WriteHalf},
|
||||
io::{WriteHalf, split},
|
||||
net::{TcpListener, TcpStream},
|
||||
};
|
||||
use tokio_util::codec::FramedRead;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
time::Instant,
|
||||
};
|
||||
@ -9,7 +9,7 @@ use std::{
|
||||
use actix::*;
|
||||
use actix_files::{Files, NamedFile};
|
||||
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;
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -18,15 +18,17 @@ async fn main() {
|
||||
let mut cmd_rx = UnboundedReceiverStream::new(cmd_rx);
|
||||
|
||||
// run blocking terminal input reader on separate thread
|
||||
let input_thread = thread::spawn(move || loop {
|
||||
let mut cmd = String::with_capacity(32);
|
||||
let input_thread = thread::spawn(move || {
|
||||
loop {
|
||||
let mut cmd = String::with_capacity(32);
|
||||
|
||||
if io::stdin().read_line(&mut cmd).is_err() {
|
||||
log::error!("error reading line");
|
||||
return;
|
||||
if io::stdin().read_line(&mut cmd).is_err() {
|
||||
log::error!("error reading line");
|
||||
return;
|
||||
}
|
||||
|
||||
cmd_tx.send(cmd).unwrap();
|
||||
}
|
||||
|
||||
cmd_tx.send(cmd).unwrap();
|
||||
});
|
||||
|
||||
let (res, mut ws) = awc::Client::new()
|
||||
|
@ -3,8 +3,8 @@ use std::time::{Duration, Instant};
|
||||
use actix_web::web;
|
||||
use actix_ws::Message;
|
||||
use futures_util::{
|
||||
future::{self, Either},
|
||||
StreamExt as _,
|
||||
future::{self, Either},
|
||||
};
|
||||
use tokio::{pin, select, sync::broadcast, time::interval};
|
||||
|
||||
|
@ -6,7 +6,7 @@ use std::io;
|
||||
|
||||
use actix_files::NamedFile;
|
||||
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;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
//! Open `http://localhost:8080/` in browser to test.
|
||||
|
||||
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;
|
||||
|
||||
mod server;
|
||||
|
Loading…
x
Reference in New Issue
Block a user