Merge pull request #391 from meilisearch/fix-one-document-route

Do not expect a JSON value as a document indentifer
This commit is contained in:
Clément Renault 2019-12-09 21:53:04 +01:00 committed by GitHub
commit 216cccbfba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 9 deletions

View File

@ -4,7 +4,6 @@ use crate::Data;
use chrono::Utc;
use heed::types::{SerdeBincode, Str};
use meilisearch_core::Index;
use serde_json::Value;
use tide::Context;
pub trait ContextExt {
@ -103,14 +102,8 @@ impl ContextExt for Context<Data> {
fn identifier(&self) -> Result<String, ResponseError> {
let name = self
.param::<Value>("identifier")
.as_ref()
.map(meilisearch_core::serde::value_to_string)
.map_err(|e| ResponseError::bad_parameter("identifier", e))?
.ok_or(ResponseError::bad_parameter(
"identifier",
"missing parameter",
))?;
.param::<String>("identifier")
.map_err(|e| ResponseError::bad_parameter("identifier", e))?;
Ok(name)
}