Rename browse_documents into get_all_documents and always respond HTTP Ok

This commit is contained in:
Quentin de Quelen 2019-11-20 14:18:21 +01:00
parent 530738cfe9
commit 1f1cb1f501
2 changed files with 5 additions and 11 deletions

View File

@ -74,7 +74,7 @@ struct BrowseQuery {
attributes_to_retrieve: Option<String>, attributes_to_retrieve: Option<String>,
} }
pub async fn browse_documents(ctx: Context<Data>) -> SResult<Response> { pub async fn get_all_documents(ctx: Context<Data>) -> SResult<Response> {
ctx.is_allowed(DocumentsRead)?; ctx.is_allowed(DocumentsRead)?;
let index = ctx.index()?; let index = ctx.index()?;
@ -114,16 +114,10 @@ pub async fn browse_documents(ctx: Context<Data>) -> SResult<Response> {
} }
} }
if response_body.is_empty() {
Ok(tide::response::json(response_body)
.with_status(StatusCode::NO_CONTENT)
.into_response())
} else {
Ok(tide::response::json(response_body) Ok(tide::response::json(response_body)
.with_status(StatusCode::OK) .with_status(StatusCode::OK)
.into_response()) .into_response())
} }
}
fn infered_schema(document: &IndexMap<String, Value>) -> Option<meilidb_schema::Schema> { fn infered_schema(document: &IndexMap<String, Value>) -> Option<meilidb_schema::Schema> {
use meilidb_schema::{SchemaBuilder, DISPLAYED, INDEXED}; use meilidb_schema::{SchemaBuilder, DISPLAYED, INDEXED};

View File

@ -42,7 +42,7 @@ pub fn load_routes(app: &mut tide::App<Data>) {
router.at("/documents").nest(|router| { router.at("/documents").nest(|router| {
router router
.at("/") .at("/")
.get(document::browse_documents) .get(document::get_all_documents)
.post(document::add_or_replace_multiple_documents) .post(document::add_or_replace_multiple_documents)
.put(document::add_or_update_multiple_documents) .put(document::add_or_update_multiple_documents)
.delete(document::clear_all_documents); .delete(document::clear_all_documents);