Skip to content

Commit 0724caf

Browse files
committed
Fix cookies subject in search
1 parent d4642ed commit 0724caf

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};
@@ -48,6 +49,7 @@ pub async fn search_query(
4849
appstate: web::Data<AppState>,
4950
params: web::Query<SearchQuery>,
5051
req: actix_web::HttpRequest,
52+
conn: actix_web::dev::ConnectionInfo,
5153
) -> AtomicServerResult<HttpResponse> {
5254
let mut timer = Timer::new();
5355
let store = &appstate.store;
@@ -76,19 +78,7 @@ pub async fn search_query(
7678
let subjects = docs_to_subjects(top_docs, &fields, &searcher)?;
7779

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

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

0 commit comments

Comments
 (0)