@@ -9,6 +9,7 @@ use std::collections::HashSet;
9
9
use crate :: {
10
10
appstate:: AppState ,
11
11
errors:: { AtomicServerError , AtomicServerResult } ,
12
+ helpers:: get_subject,
12
13
search:: { resource_to_facet, Fields } ,
13
14
} ;
14
15
use actix_web:: { web, HttpResponse } ;
@@ -36,6 +37,7 @@ pub async fn search_query(
36
37
appstate : web:: Data < AppState > ,
37
38
params : web:: Query < SearchQuery > ,
38
39
req : actix_web:: HttpRequest ,
40
+ conn : actix_web:: dev:: ConnectionInfo ,
39
41
) -> AtomicServerResult < HttpResponse > {
40
42
let store = & appstate. store ;
41
43
let searcher = appstate. search_state . reader . searcher ( ) ;
@@ -91,19 +93,7 @@ pub async fn search_query(
91
93
let subjects = docs_to_resources ( top_docs, & fields, & searcher) ?;
92
94
93
95
// 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) ?;
107
97
108
98
let mut results_resource = atomic_lib:: plugins:: search:: search_endpoint ( ) . to_resource ( store) ?;
109
99
results_resource. set_subject ( subject. clone ( ) ) ;
0 commit comments