@@ -9,6 +9,7 @@ use std::collections::HashSet;
99use  crate :: { 
1010    appstate:: AppState , 
1111    errors:: { AtomicServerError ,  AtomicServerResult } , 
12+     helpers:: get_subject, 
1213    search:: { resource_to_facet,  Fields } , 
1314} ; 
1415use  actix_web:: { web,  HttpResponse } ; 
@@ -36,6 +37,7 @@ pub async fn search_query(
3637    appstate :  web:: Data < AppState > , 
3738    params :  web:: Query < SearchQuery > , 
3839    req :  actix_web:: HttpRequest , 
40+     conn :  actix_web:: dev:: ConnectionInfo , 
3941)  -> AtomicServerResult < HttpResponse >  { 
4042    let  store = & appstate. store ; 
4143    let  searcher = appstate. search_state . reader . searcher ( ) ; 
@@ -91,19 +93,7 @@ pub async fn search_query(
9193    let  subjects = docs_to_resources ( top_docs,  & fields,  & searcher) ?; 
9294
9395    // Create a valid atomic data resource. 
94-     // You'd think there would be a simpler way of getting the requested URL... 
95-     // See https://github.com/actix/actix-web/issues/2895 
96-     let  subject:  String  = store
97-         . get_self_url ( ) 
98-         . ok_or ( "No base URL set" ) ?
99-         . url ( ) 
100-         . join ( 
101-             req. uri ( ) 
102-                 . path_and_query ( ) 
103-                 . ok_or ( "Add a query param" ) ?
104-                 . as_str ( ) , 
105-         ) ?
106-         . to_string ( ) ; 
96+     let  subject:  String  = get_subject ( & req,  & conn,  & appstate) ?; 
10797
10898    let  mut  results_resource = atomic_lib:: plugins:: search:: search_endpoint ( ) . to_resource ( store) ?; 
10999    results_resource. set_subject ( subject. clone ( ) ) ; 
0 commit comments