fts wip: trigger, Quote::get_by_search_query, expose to API
This commit is contained in:
@@ -50,4 +50,5 @@ pub fn api_router() -> Router<MnemoState> {
|
||||
// quotes
|
||||
.route("/api/quotes", post(quotes::create))
|
||||
.route("/api/quotes/{id}", get(quotes::get_by_id))
|
||||
.route("/api/quotes/search", get(quotes::get_by_query))
|
||||
}
|
||||
|
||||
@@ -30,6 +30,16 @@ pub async fn get_by_id(
|
||||
Ok(Json(Quote::get_by_id(&mut conn, id).await?).into_response())
|
||||
}
|
||||
|
||||
pub async fn get_by_query(
|
||||
State(state): State<MnemoState>,
|
||||
headers: HeaderMap,
|
||||
Json(q): Json<String>,
|
||||
) -> Result<Response, CompositeError> {
|
||||
let mut conn = state.pool.acquire().await?;
|
||||
User::authenticate(&mut conn, &headers).await?.required()?;
|
||||
Ok(Json(Quote::get_by_search_query(&mut conn, &q).await?).into_response())
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct QuoteLineForm {
|
||||
pub content: String,
|
||||
|
||||
Reference in New Issue
Block a user