mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-08 11:01:35 +00:00
HACK: Multiple versions of actix in support package with features
This commit is contained in:
1 parent
8a00f37e9e
commit
d209e7fd79
9 files changed
+57
-109
No files matched your search
Generated
+2
-30
@@ -2044,47 +2044,19 @@ dependencies = [
|
||||
name = "http_server_common"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-http 2.2.0",
|
||||
"actix-http 3.0.0-beta.11",
|
||||
"actix-web 3.3.2",
|
||||
"actix-web 4.0.0-beta.10",
|
||||
"anyhow",
|
||||
"base64 0.13.0",
|
||||
"bcrypt",
|
||||
"chrono",
|
||||
"data-encoding",
|
||||
"derive_more",
|
||||
"diesel",
|
||||
"dotenv",
|
||||
"easyenv",
|
||||
"futures 0.1.31",
|
||||
"futures 0.3.17",
|
||||
"hex",
|
||||
"hmac 0.10.1",
|
||||
"hostname",
|
||||
"hyper 0.13.10",
|
||||
"infer",
|
||||
"limitation",
|
||||
"log",
|
||||
"lru_time_cache",
|
||||
"magic-crypt",
|
||||
"md-5",
|
||||
"pulldown-cmark",
|
||||
"r2d2_redis",
|
||||
"rand 0.8.4",
|
||||
"regex",
|
||||
"ring 0.17.0-alpha.10",
|
||||
"rust-s3",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"sqlx",
|
||||
"subprocess",
|
||||
"tempdir",
|
||||
"time 0.2.26",
|
||||
"tokio 0.2.25",
|
||||
"toml",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -18,74 +18,24 @@ path = "src/lib.rs"
|
||||
anyhow = "1.0.40"
|
||||
base64 = "0.13.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
derive_more = "0.99.14"
|
||||
dotenv = "0.15.0"
|
||||
easyenv = "0.0.6"
|
||||
futures = { version = "0.3.15", features = ["thread-pool"] } # feature for ThreadPool
|
||||
futures_old_for_limiter = { package = "futures", version = "0.1.29" } # Older version of futures for `limiter` crate
|
||||
hex = "0.4.3"
|
||||
hostname = "0.3.1"
|
||||
log = "0.4.14"
|
||||
rand = "0.8.3"
|
||||
regex = "1.5.4"
|
||||
time = "0.2.26"
|
||||
uuid = { version = "0.8.2", features = ["v4"] }
|
||||
|
||||
# Runtime
|
||||
# NB(1): We switched to Tokio from `async-std` for broader ecosystem support.
|
||||
#async-std = { version = "1.6", features = [ "attributes" ] }
|
||||
# NB(2): Really unfortunate. We can't use Tokio 1.x due to a bug in `rust-s3` that I filed:
|
||||
# https://github.com/durch/rust-s3/issues/198
|
||||
#tokio = { version = "1.6.0", features = ["macros"] }
|
||||
tokio = { version = "0.2.25", features = ["macros"] }
|
||||
|
||||
# MySql Database
|
||||
# "offline" supports typesafe builds without a live database
|
||||
# "rustls" doesn't appear to work with IP addresses, per:
|
||||
# https://github.com/launchbadge/sqlx/issues/1095#issuecomment-798050828
|
||||
#sqlx = { version = "0.5", features = [ "mysql", "runtime-async-std-native-tls", "offline", "chrono" ] }
|
||||
# NB: We can't use `sqlx` 0.5 due to the `rust-s3` bug that requires a Tokio 1.x -> 0.2 downgrade
|
||||
#sqlx = { version = "0.5", features = [ "mysql", "runtime-actix-native-tls", "offline", "chrono" ] }
|
||||
sqlx = { version = "0.4", features = [ "mysql", "runtime-tokio-native-tls", "offline", "chrono" ] }
|
||||
|
||||
# Redis Database
|
||||
limitation = "0.1.1" # Redis rate limiter
|
||||
r2d2_redis = "0.14.0"
|
||||
|
||||
# In-memory caching
|
||||
lru_time_cache = "0.11.11"
|
||||
|
||||
# Files
|
||||
data-encoding = "2.3.2"
|
||||
ring = "0.17.0-alpha.10"
|
||||
# NB: This is the source of all of our problems. `rust-s3` can't upload to object names with directories
|
||||
# in the 0.27.* series, so we have to downgrade to 0.26, which includes a broad downgrade from Tokio 1.0 -> 0.2
|
||||
#rust-s3 = "0.27.0-rc4"
|
||||
#rust-s3 = { version = "0.27.0-rc4", features = ["with-async-std"], default-features = false }
|
||||
rust-s3 = { version = "0.26" }
|
||||
infer = "0.5.0"
|
||||
|
||||
subprocess = "0.2.6"
|
||||
tempdir = "0.3.7"
|
||||
|
||||
# Web
|
||||
actix-cors = "0.5.4"
|
||||
|
||||
# NB: Versions aren't pinned since some apps use ver 3 vs ver 4.
|
||||
# This is because of the Tokio runtime requirements.
|
||||
actix-http = "*"
|
||||
actix-web = "*"
|
||||
#actix-http = "*"
|
||||
#actix-web = "*"
|
||||
#actix-http = "3.0.0-beta.11"
|
||||
#actix-http = "2.2.0"
|
||||
#actix-web = "4.0.0-beta.10"
|
||||
#actix-web = "3.3.2"
|
||||
|
||||
# NB: Hyper is just for HTTP client use in jobs. I'd use Actix client, but I need tokio runtime
|
||||
# NB: Furthermore, the Tokio runtime is old, so I have to use an older Hyper.
|
||||
hyper = { version = "0.13.10" }
|
||||
actix-http-old = { package = "actix-http", version = "2.2.0", optional = true }
|
||||
actix-web-old = { package = "actix-web", version = "3.3.2", optional = true }
|
||||
|
||||
# Crypto
|
||||
bcrypt = "0.8" # password hashes
|
||||
hmac = "0.10.0" # cookies
|
||||
magic-crypt = "3.1.8" # encrypting sort IDs for the frontend so we don't leak info
|
||||
md-5 = "0.9.1" # gravatar
|
||||
sha2 = "0.9.5" # file hashes, inference text hashes, etc.
|
||||
actix-http-new = { package = "actix-http", version = "3.0.0-beta.11", optional = true }
|
||||
actix-web-new = { package = "actix-web", version = "4.0.0-beta.10", optional = true }
|
||||
|
||||
# Serialization
|
||||
serde = "1.0.125"
|
||||
@@ -93,9 +43,6 @@ serde_derive = "1.0.125"
|
||||
serde_json = "1.0.64"
|
||||
toml = "0.5.8"
|
||||
|
||||
# Text processing
|
||||
pulldown-cmark = "0.8.0"
|
||||
|
||||
[build-dependencies]
|
||||
# NB: Only using diesel for migrations support
|
||||
diesel = { version = "1.4.6", features = ["mysql"] }
|
||||
[features]
|
||||
actix-new = ["actix-http-new", "actix-web-new"]
|
||||
actix-old = ["actix-http-old", "actix-web-old"]
|
||||
@@ -4,6 +4,24 @@
|
||||
|
||||
#[macro_use] extern crate serde_derive;
|
||||
|
||||
pub mod cors;
|
||||
// This is a little messy since we're supporting two versions of the Actix crate ecosystem.
|
||||
// Long story short: one service requires an old Tokio runtime, and another needs the newer one.
|
||||
//
|
||||
// I don't think this will be too hard to maintain. AFAICT, the only major differences are which
|
||||
// package "HttpResponseBuilder" is located in.
|
||||
|
||||
#[cfg(feature = "actix-new")]
|
||||
extern crate actix_http_new as actix_http;
|
||||
|
||||
#[cfg(feature = "actix-new")]
|
||||
extern crate actix_web_new as actix_web;
|
||||
|
||||
#[cfg(feature = "actix-old")]
|
||||
extern crate actix_http_old as actix_http;
|
||||
|
||||
#[cfg(feature = "actix-old")]
|
||||
extern crate actix_web_old as actix_web;
|
||||
|
||||
//pub mod cors;
|
||||
pub mod endpoints;
|
||||
pub mod response;
|
||||
@@ -1,8 +1,13 @@
|
||||
use actix_http::http::header;
|
||||
use actix_web::dev::HttpResponseBuilder;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::{HttpResponse, ResponseError};
|
||||
|
||||
#[cfg(feature = "actix-web-old")]
|
||||
use actix_web::dev::HttpResponseBuilder;
|
||||
|
||||
#[cfg(feature = "actix-web-new")]
|
||||
use actix_web::HttpResponseBuilder;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct SimpleGenericJsonError {
|
||||
pub success: bool,
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
use actix_http::ResponseError;
|
||||
use actix_http::http::{StatusCode, header};
|
||||
use actix_web::HttpResponse;
|
||||
use actix_web::dev::HttpResponseBuilder;
|
||||
use serde::Serialize;
|
||||
|
||||
#[cfg(feature = "actix-http-new")]
|
||||
use actix_web::error::ResponseError;
|
||||
|
||||
#[cfg(feature = "actix-http-old")]
|
||||
use actix_http::ResponseError;
|
||||
|
||||
#[cfg(feature = "actix-web-old")]
|
||||
use actix_web::dev::HttpResponseBuilder;
|
||||
|
||||
#[cfg(feature = "actix-web-new")]
|
||||
use actix_web::HttpResponseBuilder;
|
||||
|
||||
/// Turn error responses into JSON HTTP responses
|
||||
pub fn serialize_as_json_error<T>(
|
||||
error_payload: &T,
|
||||
|
||||
@@ -17,7 +17,7 @@ path = "src/main.rs"
|
||||
# Internal
|
||||
config = { path = "../config" }
|
||||
container_common = { path = "../container_common" }
|
||||
http_server_common = { path = "../http_server_common" }
|
||||
http_server_common = { path = "../http_server_common", features = ["actix-new"] }
|
||||
|
||||
# External
|
||||
anyhow = "1.0.40"
|
||||
|
||||
@@ -46,9 +46,5 @@ pub async fn oauth_begin_enroll(
|
||||
|
||||
|
||||
info!("oauth enrollment begin");
|
||||
//Ok(simple_json_success())
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("application/json")
|
||||
.body(""))
|
||||
Ok(simple_json_success())
|
||||
}
|
||||
@@ -31,7 +31,7 @@ use crate::twitch::twitch_secrets::TwitchSecrets;
|
||||
use crate::twitch::websocket_client::PollingTwitchWebsocketClient;
|
||||
use futures::Future;
|
||||
use futures::executor::ThreadPool;
|
||||
use http_server_common::cors::build_common_cors_config;
|
||||
//use http_server_common::cors::build_common_cors_config;
|
||||
use http_server_common::endpoints::default_route_404::default_route_404;
|
||||
use http_server_common::endpoints::root_index::get_root_index;
|
||||
use limitation::Limiter;
|
||||
|
||||
@@ -102,7 +102,7 @@ use crate::util::caching::single_item_ttl_cache::SingleItemTtlCache;
|
||||
use crate::util::encrypted_sort_id::SortKeyCrypto;
|
||||
use futures::Future;
|
||||
use futures::executor::ThreadPool;
|
||||
use http_server_common::cors::build_common_cors_config;
|
||||
//use http_server_common::cors::build_common_cors_config;
|
||||
use http_server_common::endpoints::default_route_404::default_route_404;
|
||||
use http_server_common::endpoints::root_index::get_root_index;
|
||||
use limitation::Limiter;
|
||||
@@ -318,7 +318,7 @@ pub async fn serve(server_state: ServerState) -> AnyhowResult<()>
|
||||
|
||||
App::new()
|
||||
.app_data(server_state_arc.clone())
|
||||
.wrap(build_common_cors_config())
|
||||
//.wrap(build_common_cors_config())
|
||||
.wrap(Logger::new(&log_format)
|
||||
.exclude("/liveness")
|
||||
.exclude("/readiness"))
|
||||
|
||||
Reference in new issue
Block a user