mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2025-11-05 00:34:50 +00:00
* platform: fix build on Linux and update web-view * deps: replace xz-decom with xz2 and update deps * platform: fix regression... ... that prevents the build on Windows * linux: implement platform-dependent functions * travis: add macos and windows CI * travis: use official Rust Docker image * Update Cargo.lock for new version * Break apart REST into separate services This cleans up locking, ensures consistent futures for all endpoints and enhances code re-use. * Clean up codebase, fixing minor errors * Update packages, use async client for downloading config While this has a hell of a lot more boilerplate, this is quite a bit cleaner. * Add explicit 'dyn's as per Rust nightly requirements * Migrate self updating functions to own module * Migrate assets to server module * Use patched web-view to fix dialogs, remove nfd * Implement basic dark mode * Revert window.close usage * ui: split files and use Webpack * frontend: ui: include prebuilt assets... ... and update rust side stuff * build: integrate webpack building into build.rs * Polish Vue UI split * Add instructions for node + yarn * native: fix uninstall self-destruction behavior...... by not showing the command prompt window and fork-spawning the cmd * native: deal with Unicode issues in native APIs * native: further improve Unicode support on Windows * travis: add cache and fix issues * ui: use Buefy components to... ... beautify the UI * ui: makes error message selectable * Make launcher mode behaviour more robust * Fix error display on launcher pages * Correctly handle exit on error * Bump installer version
85 lines
2.8 KiB
Rust
85 lines
2.8 KiB
Rust
//! frontend/rest/services/config.rs
|
|
//!
|
|
//! The /api/config call returns the current installer framework configuration.
|
|
//!
|
|
//! This endpoint should be usable directly from a <script> tag during loading.
|
|
|
|
use frontend::rest::services::Future;
|
|
use frontend::rest::services::Request;
|
|
use frontend::rest::services::Response;
|
|
use frontend::rest::services::WebService;
|
|
|
|
use hyper::header::{ContentLength, ContentType};
|
|
|
|
use logging::LoggingErrors;
|
|
|
|
use config::Config;
|
|
|
|
use http::build_async_client;
|
|
|
|
use futures::stream::Stream;
|
|
use futures::Future as _;
|
|
|
|
pub fn handle(service: &WebService, _req: Request) -> Future {
|
|
let framework_url = {
|
|
service
|
|
.get_framework_read()
|
|
.base_attributes
|
|
.target_url
|
|
.clone()
|
|
};
|
|
|
|
info!("Downloading configuration from {:?}...", framework_url);
|
|
|
|
let framework = service.framework.clone();
|
|
|
|
// Hyper doesn't allow for clients to do sync network operations in a async future.
|
|
// This smallish pipeline joins the two together.
|
|
Box::new(
|
|
build_async_client()
|
|
.log_expect("Failed to build async client")
|
|
.get(&framework_url)
|
|
.send()
|
|
.map_err(|x| {
|
|
error!("HTTP error while downloading configuration file: {:?}", x);
|
|
hyper::Error::Incomplete
|
|
})
|
|
.and_then(|x| {
|
|
x.into_body().concat2().map_err(|x| {
|
|
error!("HTTP error while parsing configuration file: {:?}", x);
|
|
hyper::Error::Incomplete
|
|
})
|
|
})
|
|
.and_then(move |x| {
|
|
let x = String::from_utf8(x.to_vec()).map_err(|x| {
|
|
error!("UTF-8 error while parsing configuration file: {:?}", x);
|
|
hyper::Error::Incomplete
|
|
})?;
|
|
|
|
let config = Config::from_toml_str(&x).map_err(|x| {
|
|
error!("Serde error while parsing configuration file: {:?}", x);
|
|
hyper::Error::Incomplete
|
|
})?;
|
|
|
|
let mut framework = framework
|
|
.write()
|
|
.log_expect("Failed to get write lock for framework");
|
|
|
|
framework.config = Some(config);
|
|
|
|
info!("Configuration file downloaded successfully.");
|
|
|
|
let file = framework
|
|
.get_config()
|
|
.log_expect("Config should be loaded by now")
|
|
.to_json_str()
|
|
.log_expect("Failed to render JSON representation of config");
|
|
|
|
Ok(Response::new()
|
|
.with_header(ContentLength(file.len() as u64))
|
|
.with_header(ContentType::json())
|
|
.with_body(file))
|
|
}),
|
|
)
|
|
}
|