mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
review fixes
This commit is contained in:
parent
e4bd1bc5ce
commit
c2461e5066
9 changed files with 102 additions and 425 deletions
|
@ -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 {
|
||||
|
|
|
@ -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#"
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue