mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
cargo fmt
This commit is contained in:
parent
f182afc50b
commit
dda08d60d2
14 changed files with 77 additions and 67 deletions
|
@ -145,7 +145,7 @@ async fn update_multiple_documents(mut ctx: Request<Data>, is_partial: bool) ->
|
|||
None => return Err(ResponseError::bad_request("Could not infer a schema")),
|
||||
},
|
||||
};
|
||||
let settings_update = SettingsUpdate{
|
||||
let settings_update = SettingsUpdate {
|
||||
identifier: UpdateState::Update(id),
|
||||
..SettingsUpdate::default()
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@ pub async fn list_indexes(ctx: Request<Data>) -> SResult<Response> {
|
|||
|
||||
let identifier = match index.main.schema(&reader) {
|
||||
Ok(Some(schema)) => Some(schema.identifier().to_owned()),
|
||||
_ => None
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let index_response = IndexResponse {
|
||||
|
@ -89,7 +89,7 @@ pub async fn get_index(ctx: Request<Data>) -> SResult<Response> {
|
|||
|
||||
let identifier = match index.main.schema(&reader) {
|
||||
Ok(Some(schema)) => Some(schema.identifier().to_owned()),
|
||||
_ => None
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let response_body = IndexResponse {
|
||||
|
@ -97,7 +97,7 @@ pub async fn get_index(ctx: Request<Data>) -> SResult<Response> {
|
|||
uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
identifier
|
||||
identifier,
|
||||
};
|
||||
|
||||
Ok(tide::Response::new(200).body_json(&response_body)?)
|
||||
|
@ -220,9 +220,13 @@ pub async fn update_index(mut ctx: Request<Data>) -> SResult<Response> {
|
|||
|
||||
if let Some(identifier) = body.identifier {
|
||||
if let Ok(Some(_)) = index.main.schema(&writer) {
|
||||
return Err(ResponseError::bad_request("The index identifier cannot be updated"));
|
||||
return Err(ResponseError::bad_request(
|
||||
"The index identifier cannot be updated",
|
||||
));
|
||||
}
|
||||
index.main.put_schema(&mut writer, &Schema::with_identifier(&identifier))?;
|
||||
index
|
||||
.main
|
||||
.put_schema(&mut writer, &Schema::with_identifier(&identifier))?;
|
||||
}
|
||||
|
||||
index.main.put_updated_at(&mut writer)?;
|
||||
|
@ -235,7 +239,7 @@ pub async fn update_index(mut ctx: Request<Data>) -> SResult<Response> {
|
|||
|
||||
let identifier = match index.main.schema(&reader) {
|
||||
Ok(Some(schema)) => Some(schema.identifier().to_owned()),
|
||||
_ => None
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let response_body = UpdateIndexResponse {
|
||||
|
@ -243,7 +247,7 @@ pub async fn update_index(mut ctx: Request<Data>) -> SResult<Response> {
|
|||
uid: index_uid,
|
||||
created_at,
|
||||
updated_at,
|
||||
identifier
|
||||
identifier,
|
||||
};
|
||||
|
||||
Ok(tide::Response::new(200).body_json(&response_body)?)
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
use tide::{Request, Response};
|
||||
use serde_json::json;
|
||||
use crate::error::SResult;
|
||||
use crate::helpers::tide::RequestExt;
|
||||
use crate::helpers::tide::ACL::*;
|
||||
use crate::Data;
|
||||
use serde_json::json;
|
||||
use tide::{Request, Response};
|
||||
|
||||
pub async fn list(ctx: Request<Data>) -> SResult<Response> {
|
||||
ctx.is_allowed(Admin)?;
|
||||
|
||||
let keys = &ctx.state().api_keys;
|
||||
|
||||
Ok(tide::Response::new(200)
|
||||
.body_json(&json!({
|
||||
"private": keys.private,
|
||||
"public": keys.public,
|
||||
}))?)
|
||||
Ok(tide::Response::new(200).body_json(&json!({
|
||||
"private": keys.private,
|
||||
"public": keys.public,
|
||||
}))?)
|
||||
}
|
||||
|
|
|
@ -23,19 +23,15 @@ async fn into_response<T: IntoResponse, U: IntoResponse>(
|
|||
}
|
||||
|
||||
pub fn load_routes(app: &mut tide::Server<Data>) {
|
||||
app.at("/").get(|_| {
|
||||
async move {
|
||||
tide::Response::new(200)
|
||||
.body_string(include_str!("../../public/interface.html").to_string())
|
||||
.set_mime(mime::TEXT_HTML_UTF_8)
|
||||
}
|
||||
app.at("/").get(|_| async {
|
||||
tide::Response::new(200)
|
||||
.body_string(include_str!("../../public/interface.html").to_string())
|
||||
.set_mime(mime::TEXT_HTML_UTF_8)
|
||||
});
|
||||
app.at("/bulma.min.css").get(|_| {
|
||||
async {
|
||||
tide::Response::new(200)
|
||||
.body_string(include_str!("../../public/bulma.min.css").to_string())
|
||||
.set_mime(mime::TEXT_CSS_UTF_8)
|
||||
}
|
||||
app.at("/bulma.min.css").get(|_| async {
|
||||
tide::Response::new(200)
|
||||
.body_string(include_str!("../../public/bulma.min.css").to_string())
|
||||
.set_mime(mime::TEXT_CSS_UTF_8)
|
||||
});
|
||||
|
||||
app.at("/indexes")
|
||||
|
@ -117,8 +113,7 @@ pub fn load_routes(app: &mut tide::Server<Data>) {
|
|||
app.at("/indexes/:index/stats")
|
||||
.get(|ctx| into_response(stats::index_stats(ctx)));
|
||||
|
||||
app.at("/keys/")
|
||||
.get(|ctx| into_response(key::list(ctx)));
|
||||
app.at("/keys/").get(|ctx| into_response(key::list(ctx)));
|
||||
|
||||
app.at("/health")
|
||||
.get(|ctx| into_response(health::get_health(ctx)))
|
||||
|
|
|
@ -7,10 +7,10 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tide::{Request, Response};
|
||||
|
||||
use crate::helpers::tide::ACL::*;
|
||||
use crate::error::{ResponseError, SResult};
|
||||
use crate::helpers::meilisearch::{Error, IndexSearchExt, SearchHit};
|
||||
use crate::helpers::tide::RequestExt;
|
||||
use crate::helpers::tide::ACL::*;
|
||||
use crate::Data;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
|
@ -46,7 +46,9 @@ pub async fn get_all(ctx: Request<Data>) -> SResult<Response> {
|
|||
None
|
||||
};
|
||||
|
||||
let ranking_rules = index.main.ranking_rules(&reader)?
|
||||
let ranking_rules = index
|
||||
.main
|
||||
.ranking_rules(&reader)?
|
||||
.unwrap_or(DEFAULT_RANKING_RULES.to_vec())
|
||||
.into_iter()
|
||||
.map(|r| r.to_string())
|
||||
|
@ -57,7 +59,8 @@ pub async fn get_all(ctx: Request<Data>) -> SResult<Response> {
|
|||
let schema = index.main.schema(&reader)?;
|
||||
|
||||
let searchable_attributes = schema.clone().map(|s| {
|
||||
let attrs = s.indexed_name()
|
||||
let attrs = s
|
||||
.indexed_name()
|
||||
.iter()
|
||||
.map(|s| (*s).to_string())
|
||||
.collect::<Vec<String>>();
|
||||
|
@ -69,7 +72,8 @@ pub async fn get_all(ctx: Request<Data>) -> SResult<Response> {
|
|||
});
|
||||
|
||||
let displayed_attributes = schema.clone().map(|s| {
|
||||
let attrs = s.displayed_name()
|
||||
let attrs = s
|
||||
.displayed_name()
|
||||
.iter()
|
||||
.map(|s| (*s).to_string())
|
||||
.collect::<HashSet<String>>();
|
||||
|
@ -163,7 +167,9 @@ pub async fn get_rules(ctx: Request<Data>) -> SResult<Response> {
|
|||
let db = &ctx.state().db;
|
||||
let reader = db.main_read_txn()?;
|
||||
|
||||
let ranking_rules = index.main.ranking_rules(&reader)?
|
||||
let ranking_rules = index
|
||||
.main
|
||||
.ranking_rules(&reader)?
|
||||
.unwrap_or(DEFAULT_RANKING_RULES.to_vec())
|
||||
.into_iter()
|
||||
.map(|r| r.to_string())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue