1717 */
1818
1919use crate :: {
20- handlers:: { http:: ingest:: PostError , STREAM_NAME_HEADER_KEY } ,
20+ handlers:: http:: ingest:: PostError ,
2121 option:: CONFIG ,
2222 storage:: { object_storage:: filter_path, ObjectStorageError } ,
2323 users:: filters:: { Filter , CURRENT_FILTER_VERSION , FILTERS } ,
@@ -33,15 +33,7 @@ pub async fn list(req: HttpRequest) -> Result<impl Responder, FiltersError> {
3333 . match_info ( )
3434 . get ( "user_id" )
3535 . ok_or ( FiltersError :: Metadata ( "No User Id Provided" ) ) ?;
36- let stream_name = req
37- . headers ( )
38- . iter ( )
39- . find ( |& ( key, _) | key == STREAM_NAME_HEADER_KEY )
40- . ok_or_else ( || FiltersError :: Metadata ( "Stream Name Not Provided" ) ) ?
41- . 1
42- . to_str ( )
43- . map_err ( |_| FiltersError :: Metadata ( "Non ASCII Stream Name Provided" ) ) ?;
44- let filters = FILTERS . list_filters_by_user_and_stream ( user_id, stream_name) ;
36+ let filters = FILTERS . list_filters_by_user ( user_id) ;
4537
4638 Ok ( ( web:: Json ( filters) , StatusCode :: OK ) )
4739}
@@ -59,7 +51,7 @@ pub async fn get(req: HttpRequest) -> Result<impl Responder, FiltersError> {
5951 Err ( FiltersError :: Metadata ( "Filter Not Found" ) )
6052}
6153
62- pub async fn post ( body : Bytes ) -> Result < HttpResponse , PostError > {
54+ pub async fn post ( body : Bytes ) -> Result < impl Responder , PostError > {
6355 let filter: Filter = serde_json:: from_slice ( & body) ?;
6456 let filter_id = rand:: distributions:: Alphanumeric . sample_string ( & mut rand:: thread_rng ( ) , 10 ) ;
6557 let user_id = & filter. user_id ;
@@ -75,7 +67,7 @@ pub async fn post(body: Bytes) -> Result<HttpResponse, PostError> {
7567 let filter_bytes = serde_json:: to_vec ( & cloned_filter) ?;
7668 store. put_object ( & path, Bytes :: from ( filter_bytes) ) . await ?;
7769
78- Ok ( HttpResponse :: Ok ( ) . finish ( ) )
70+ Ok ( ( web :: Json ( cloned_filter ) , StatusCode :: OK ) )
7971}
8072
8173pub async fn update ( req : HttpRequest , body : Bytes ) -> Result < HttpResponse , PostError > {
0 commit comments