mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 08:25:16 +00:00
Can serve user data files directly from the API
This commit is contained in:
@ -37,6 +37,7 @@ pub struct Config {
|
||||
pub listen_address: String,
|
||||
pub storage_url: String,
|
||||
pub storage_path: String,
|
||||
pub serve_storage_file: bool,
|
||||
pub terms_url: String,
|
||||
pub privacy_policy_url: String,
|
||||
pub play_store_url: String,
|
||||
@ -122,6 +123,8 @@ impl Config {
|
||||
storage_url: Config::yaml_str(parsed, "storage-url"),
|
||||
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"),
|
||||
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::routes::{get_routes, RequestResult, Route};
|
||||
use crate::routes::Method::{GET, POST};
|
||||
use crate::utils::user_data_utils::user_data_path;
|
||||
|
||||
/// Main server functions
|
||||
///
|
||||
@ -335,11 +336,17 @@ pub async fn start_server(conf: &Config) -> std::io::Result<()> {
|
||||
let addr = conf.server_listen_address();
|
||||
println!("Start to listen on http://{}/", addr);
|
||||
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
let serve_storage_file = conf.serve_storage_file;
|
||||
|
||||
// User WebSocket route
|
||||
.service(actix_web::web::resource("/ws").to(user_ws_controller::ws_route))
|
||||
HttpServer::new(move || {
|
||||
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
|
||||
.service(actix_web::web::resource("/rtc_proxy/ws").to(rtc_relay_controller::open_ws))
|
||||
|
Reference in New Issue
Block a user