Skip to content

Commit 4e50e2f

Browse files
committed
Fix cookies subject in search
1 parent 6cee307 commit 4e50e2f

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
@@ -9,6 +9,7 @@ use std::collections::HashSet;
99
use crate::{
1010
appstate::AppState,
1111
errors::{AtomicServerError, AtomicServerResult},
12+
helpers::get_subject,
1213
search::{resource_to_facet, Fields},
1314
};
1415
use 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

Comments
 (0)