Skip to content

Commit

Permalink
Enhancement for POST /filters
Browse files Browse the repository at this point in the history
server sends filter json with filter id as response
  • Loading branch information
nikhilsinhaparseable committed Jun 28, 2024
1 parent 22a7d87 commit 277dd1d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/src/handlers/http/users/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub async fn get(req: HttpRequest) -> Result<impl Responder, FiltersError> {
Err(FiltersError::Metadata("Filter Not Found"))
}

pub async fn post(body: Bytes) -> Result<HttpResponse, PostError> {
pub async fn post(body: Bytes) -> Result<impl Responder, PostError> {
let filter: Filter = serde_json::from_slice(&body)?;
let filter_id = rand::distributions::Alphanumeric.sample_string(&mut rand::thread_rng(), 10);
let user_id = &filter.user_id;
Expand All @@ -75,7 +75,7 @@ pub async fn post(body: Bytes) -> Result<HttpResponse, PostError> {
let filter_bytes = serde_json::to_vec(&cloned_filter)?;
store.put_object(&path, Bytes::from(filter_bytes)).await?;

Ok(HttpResponse::Ok().finish())
Ok((web::Json(cloned_filter), StatusCode::OK))
}

pub async fn update(req: HttpRequest, body: Bytes) -> Result<HttpResponse, PostError> {
Expand Down

0 comments on commit 277dd1d

Please sign in to comment.