This repository has been archived on 2024-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
2024-07-31 19:17:59 +03:00

21 lines
461 B
Rust

use futures::TryStreamExt;
use crate::prelude::*;
#[derive(Deserialize, Debug)]
pub struct Params {
search_string: String,
}
pub async fn search(
State(pool): State<Pool>,
Query(params): Query<Params>,
) -> sqlx::Result<Json<Vec<db::users::UserInfo>>, StatusCode> {
let users = db::users::search_for_user(&params.search_string, &pool)
.take(20)
.try_collect()
.await
.handle_internal()?;
Ok(Json(users))
}