Skip to content

Commit 229eba4

Browse files
committed
Fix cookies subject in search
1 parent 4989136 commit 229eba4

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

server/src/handlers/search.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use crate::{
66
appstate::AppState,
77
errors::{AtomicServerError, AtomicServerResult},
8+
helpers::get_subject,
89
search::{resource_to_facet, Fields},
910
};
1011
use actix_web::{web, HttpResponse};
@@ -47,6 +48,7 @@ pub async fn search_query(
4748
appstate: web::Data<AppState>,
4849
params: web::Query<SearchQuery>,
4950
req: actix_web::HttpRequest,
51+
conn: actix_web::dev::ConnectionInfo,
5052
) -> AtomicServerResult<HttpResponse> {
5153
let store = &appstate.store;
5254
let searcher = appstate.search_state.reader.searcher();
@@ -72,19 +74,7 @@ pub async fn search_query(
7274
let subjects = docs_to_subjects(top_docs, &fields, &searcher)?;
7375

7476
// Create a valid atomic data resource.
75-
// You'd think there would be a simpler way of getting the requested URL...
76-
// See https://github.com/actix/actix-web/issues/2895
77-
let subject: String = store
78-
.get_self_url()
79-
.ok_or("No base URL set")?
80-
.url()
81-
.join(
82-
req.uri()
83-
.path_and_query()
84-
.ok_or("Add a query param")?
85-
.as_str(),
86-
)?
87-
.to_string();
77+
let subject: String = get_subject(&req, &conn, &appstate)?;
8878

8979
let mut results_resource = atomic_lib::plugins::search::search_endpoint().to_resource(store)?;
9080
results_resource.set_subject(subject.clone());

0 commit comments

Comments
 (0)