17
17
*/
18
18
19
19
use crate :: {
20
- handlers:: { http:: ingest:: PostError , STREAM_NAME_HEADER_KEY } ,
20
+ handlers:: http:: ingest:: PostError ,
21
21
option:: CONFIG ,
22
22
storage:: { object_storage:: filter_path, ObjectStorageError } ,
23
23
users:: filters:: { Filter , CURRENT_FILTER_VERSION , FILTERS } ,
@@ -33,15 +33,7 @@ pub async fn list(req: HttpRequest) -> Result<impl Responder, FiltersError> {
33
33
. match_info ( )
34
34
. get ( "user_id" )
35
35
. 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) ;
45
37
46
38
Ok ( ( web:: Json ( filters) , StatusCode :: OK ) )
47
39
}
@@ -59,7 +51,7 @@ pub async fn get(req: HttpRequest) -> Result<impl Responder, FiltersError> {
59
51
Err ( FiltersError :: Metadata ( "Filter Not Found" ) )
60
52
}
61
53
62
- pub async fn post ( body : Bytes ) -> Result < HttpResponse , PostError > {
54
+ pub async fn post ( body : Bytes ) -> Result < impl Responder , PostError > {
63
55
let filter: Filter = serde_json:: from_slice ( & body) ?;
64
56
let filter_id = rand:: distributions:: Alphanumeric . sample_string ( & mut rand:: thread_rng ( ) , 10 ) ;
65
57
let user_id = & filter. user_id ;
@@ -75,7 +67,7 @@ pub async fn post(body: Bytes) -> Result<HttpResponse, PostError> {
75
67
let filter_bytes = serde_json:: to_vec ( & cloned_filter) ?;
76
68
store. put_object ( & path, Bytes :: from ( filter_bytes) ) . await ?;
77
69
78
- Ok ( HttpResponse :: Ok ( ) . finish ( ) )
70
+ Ok ( ( web :: Json ( cloned_filter ) , StatusCode :: OK ) )
79
71
}
80
72
81
73
pub async fn update ( req : HttpRequest , body : Bytes ) -> Result < HttpResponse , PostError > {
0 commit comments