Skip to content

Commit 0828ff3

Browse files
committed
Fix cookies subject in search
1 parent b20f813 commit 0828ff3

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};
@@ -50,6 +51,7 @@ pub async fn search_query(
5051
appstate: web::Data<AppState>,
5152
params: web::Query<SearchQuery>,
5253
req: actix_web::HttpRequest,
54+
conn: actix_web::dev::ConnectionInfo,
5355
) -> AtomicServerResult<HttpResponse> {
5456
let mut timer = Timer::new();
5557
let store = &appstate.store;
@@ -78,19 +80,7 @@ pub async fn search_query(
7880
let subjects = docs_to_subjects(top_docs, &fields, &searcher)?;
7981

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

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

0 commit comments

Comments
 (0)