mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 13:29:21 +00:00
Can serve user data files directly from the API
This commit is contained in:
parent
52ccdf26e4
commit
0ea0997a4f
88
Cargo.lock
generated
88
Cargo.lock
generated
@ -60,6 +60,26 @@ dependencies = [
|
|||||||
"trust-dns-resolver",
|
"trust-dns-resolver",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "actix-files"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c51e8a9146c12fce92a6e4c24b8c4d9b05268130bfd8d61bc587e822c32ce689"
|
||||||
|
dependencies = [
|
||||||
|
"actix-service",
|
||||||
|
"actix-web",
|
||||||
|
"bitflags",
|
||||||
|
"bytes 0.5.6",
|
||||||
|
"derive_more",
|
||||||
|
"futures-core",
|
||||||
|
"futures-util",
|
||||||
|
"log",
|
||||||
|
"mime",
|
||||||
|
"mime_guess",
|
||||||
|
"percent-encoding",
|
||||||
|
"v_htmlescape",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-http"
|
name = "actix-http"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
@ -595,6 +615,15 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "buf-min"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa17aa1cf56bdd6bb30518767d00e58019d326f3f05d8c3e0730b549d332ea83"
|
||||||
|
dependencies = [
|
||||||
|
"bytes 0.5.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bufstream"
|
name = "bufstream"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@ -728,6 +757,7 @@ name = "comunic_server"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix",
|
"actix",
|
||||||
|
"actix-files",
|
||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
@ -774,7 +804,7 @@ checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"time 0.2.25",
|
"time 0.2.25",
|
||||||
"version_check",
|
"version_check 0.9.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1221,7 +1251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"typenum",
|
"typenum",
|
||||||
"version_check",
|
"version_check 0.9.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1984,6 +2014,16 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "4.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"version_check 0.1.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ntapi"
|
name = "ntapi"
|
||||||
version = "0.3.6"
|
version = "0.3.6"
|
||||||
@ -2936,7 +2976,7 @@ version = "0.2.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2beb4d1860a61f571530b3f855a1b538d0200f7871c63331ecd6f17b1f014f8"
|
checksum = "a2beb4d1860a61f571530b3f855a1b538d0200f7871c63331ecd6f17b1f014f8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"version_check",
|
"version_check 0.9.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3156,7 +3196,7 @@ dependencies = [
|
|||||||
"standback",
|
"standback",
|
||||||
"stdweb",
|
"stdweb",
|
||||||
"time-macros",
|
"time-macros",
|
||||||
"version_check",
|
"version_check 0.9.2",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -3395,7 +3435,7 @@ version = "2.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"version_check",
|
"version_check 0.9.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3458,12 +3498,50 @@ version = "0.8.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "v_escape"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f3e0ab5fab1db278a9413d2ea794cb66f471f898c5b020c3c394f6447625d9d4"
|
||||||
|
dependencies = [
|
||||||
|
"buf-min",
|
||||||
|
"v_escape_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "v_escape_derive"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c860ad1273f4eee7006cee05db20c9e60e5d24cba024a32e1094aa8e574f3668"
|
||||||
|
dependencies = [
|
||||||
|
"nom",
|
||||||
|
"proc-macro2 1.0.24",
|
||||||
|
"quote 1.0.9",
|
||||||
|
"syn 1.0.60",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "v_htmlescape"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f9a8af610ad6f7fc9989c9d2590d9764bc61f294884e9ee93baa58795174572"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"v_escape",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vcpkg"
|
name = "vcpkg"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
|
checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.2"
|
version = "0.9.2"
|
||||||
|
@ -11,6 +11,7 @@ yaml-rust = "0.4.5"
|
|||||||
mysql = "20.1.0"
|
mysql = "20.1.0"
|
||||||
actix = "0.10.0"
|
actix = "0.10.0"
|
||||||
actix-web = "3.3.2"
|
actix-web = "3.3.2"
|
||||||
|
actix-files = "0.5.0"
|
||||||
actix-rt = "1.1.1"
|
actix-rt = "1.1.1"
|
||||||
actix-multipart = "0.3.0"
|
actix-multipart = "0.3.0"
|
||||||
actix-web-actors = "3.0.0"
|
actix-web-actors = "3.0.0"
|
||||||
|
@ -17,6 +17,11 @@ proxy: "127.0.0.1"
|
|||||||
storage-url: http://devweb.local/comunic/current/user_data/
|
storage-url: http://devweb.local/comunic/current/user_data/
|
||||||
storage-path: /home/pierre/Documents/projets_web/comunic/current/user_data/
|
storage-path: /home/pierre/Documents/projets_web/comunic/current/user_data/
|
||||||
|
|
||||||
|
# Specify whether user data files should be made available under the user_data directory
|
||||||
|
#
|
||||||
|
# It is your responsibility to update storage-url accordingly
|
||||||
|
serve-storage-files: true
|
||||||
|
|
||||||
# URL where Comunic Terms of use are available
|
# URL where Comunic Terms of use are available
|
||||||
terms-url: http://devweb.local/comunic/current/about.php?cgu
|
terms-url: http://devweb.local/comunic/current/about.php?cgu
|
||||||
privacy-policy-url: http://devweb.local/comunic/current/about.php?cgu&privacy
|
privacy-policy-url: http://devweb.local/comunic/current/about.php?cgu&privacy
|
||||||
|
@ -37,6 +37,7 @@ pub struct Config {
|
|||||||
pub listen_address: String,
|
pub listen_address: String,
|
||||||
pub storage_url: String,
|
pub storage_url: String,
|
||||||
pub storage_path: String,
|
pub storage_path: String,
|
||||||
|
pub serve_storage_file: bool,
|
||||||
pub terms_url: String,
|
pub terms_url: String,
|
||||||
pub privacy_policy_url: String,
|
pub privacy_policy_url: String,
|
||||||
pub play_store_url: String,
|
pub play_store_url: String,
|
||||||
@ -122,6 +123,8 @@ impl Config {
|
|||||||
storage_url: Config::yaml_str(parsed, "storage-url"),
|
storage_url: Config::yaml_str(parsed, "storage-url"),
|
||||||
storage_path: Config::yaml_str(parsed, "storage-path"),
|
storage_path: Config::yaml_str(parsed, "storage-path"),
|
||||||
|
|
||||||
|
serve_storage_file: Config::yaml_bool(parsed, "serve-storage-files"),
|
||||||
|
|
||||||
terms_url: Config::yaml_str(parsed, "terms-url"),
|
terms_url: Config::yaml_str(parsed, "terms-url"),
|
||||||
privacy_policy_url: Config::yaml_str(parsed, "privacy-policy-url"),
|
privacy_policy_url: Config::yaml_str(parsed, "privacy-policy-url"),
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ use crate::data::http_request_handler::HttpRequestHandler;
|
|||||||
use crate::helpers::{api_helper, requests_limit_helper};
|
use crate::helpers::{api_helper, requests_limit_helper};
|
||||||
use crate::routes::{get_routes, RequestResult, Route};
|
use crate::routes::{get_routes, RequestResult, Route};
|
||||||
use crate::routes::Method::{GET, POST};
|
use crate::routes::Method::{GET, POST};
|
||||||
|
use crate::utils::user_data_utils::user_data_path;
|
||||||
|
|
||||||
/// Main server functions
|
/// Main server functions
|
||||||
///
|
///
|
||||||
@ -335,11 +336,17 @@ pub async fn start_server(conf: &Config) -> std::io::Result<()> {
|
|||||||
let addr = conf.server_listen_address();
|
let addr = conf.server_listen_address();
|
||||||
println!("Start to listen on http://{}/", addr);
|
println!("Start to listen on http://{}/", addr);
|
||||||
|
|
||||||
HttpServer::new(|| {
|
let serve_storage_file = conf.serve_storage_file;
|
||||||
App::new()
|
|
||||||
|
|
||||||
// User WebSocket route
|
HttpServer::new(move || {
|
||||||
.service(actix_web::web::resource("/ws").to(user_ws_controller::ws_route))
|
let mut app = App::new();
|
||||||
|
|
||||||
|
if serve_storage_file {
|
||||||
|
app = app.service(actix_files::Files::new("/user_data", user_data_path("".as_ref())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// User WebSocket route
|
||||||
|
app.service(actix_web::web::resource("/ws").to(user_ws_controller::ws_route))
|
||||||
|
|
||||||
// RTC Relay WebSocket route
|
// RTC Relay WebSocket route
|
||||||
.service(actix_web::web::resource("/rtc_proxy/ws").to(rtc_relay_controller::open_ws))
|
.service(actix_web::web::resource("/rtc_proxy/ws").to(rtc_relay_controller::open_ws))
|
||||||
|
Loading…
Reference in New Issue
Block a user