review fixes

This commit is contained in:
Marin Postma 2021-04-22 12:39:23 +02:00
parent e4bd1bc5ce
commit c2461e5066
No known key found for this signature in database
GPG key ID: D5241F0C0C865F30
9 changed files with 102 additions and 425 deletions

View file

@ -9,7 +9,6 @@ pub mod routes;
pub use self::data::Data;
pub use option::Opt;
#[macro_export]
macro_rules! create_app {
($data:expr, $enable_frontend:expr) => {{
@ -52,7 +51,6 @@ macro_rules! create_app {
#[cfg(feature = "mini-dashboard")]
let app = if $enable_frontend {
let generated = dashboard::generate();
let keys = generated.keys().collect::<Vec<_>>();
let service = ResourceFiles::new("/", generated);
app.service(service)
} else {

View file

@ -72,20 +72,14 @@ async fn main() -> Result<(), MainError> {
print_launch_resume(&opt, &data);
let enable_frontend = opt.env != "production";
run_http(data, opt, enable_frontend).await?;
run_http(data, opt).await?;
Ok(())
}
#[allow(unused_variables)]
async fn run_http(
data: Data,
opt: Opt,
enable_frontend: bool,
) -> Result<(), Box<dyn std::error::Error>> {
let http_server = HttpServer::new(move || create_app!(&data, enable_frontend))
async fn run_http(data: Data, opt: Opt) -> Result<(), Box<dyn std::error::Error>> {
let _enable_dashboard = &opt.env == "development";
let http_server = HttpServer::new(move || create_app!(&data, _enable_dashboard))
// Disable signals allows the server to terminate immediately when a user enter CTRL-C
.disable_signals();
@ -103,11 +97,11 @@ async fn run_http(
pub fn print_launch_resume(opt: &Opt, data: &Data) {
let commit_sha = match option_env!("COMMIT_SHA") {
Some("") | None => env!("VERGEN_SHA"),
Some(commit_sha) => commit_sha
Some(commit_sha) => commit_sha,
};
let commit_date = match option_env!("COMMIT_DATE") {
Some("") | None => env!("VERGEN_COMMIT_DATE"),
Some(commit_date) => commit_date
Some(commit_date) => commit_date,
};
let ascii_name = r#"

View file

@ -28,14 +28,6 @@ impl IndexUpdateResponse {
}
}
/// Return the dashboard, should not be used in production. See [running]
#[get("/")]
pub async fn load_html() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(include_str!("../../public/interface.html").to_string())
}
/// Always return a 200 with:
/// ```json
/// {
@ -46,10 +38,3 @@ pub async fn load_html() -> HttpResponse {
pub async fn running() -> HttpResponse {
HttpResponse::Ok().json(serde_json::json!({ "status": "MeiliSearch is running" }))
}
#[get("/bulma.min.css")]
pub async fn load_css() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/css; charset=utf-8")
.body(include_str!("../../public/bulma.min.css").to_string())
}