Skip to content

Commit

Permalink
Fix conditional compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleiserson committed Dec 18, 2024
1 parent 7e8f21b commit fda46a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 5 additions & 3 deletions ipa-core/src/helpers/transport/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
};

pub use hybrid::HybridQueryParams;
use hyper::Uri;
use serde::{Deserialize, Deserializer, Serialize};

use crate::{
Expand Down Expand Up @@ -188,7 +187,7 @@ impl RouteParams<RouteId, QueryId, NoStep> for &PrepareQuery {
pub enum QueryInput {
FromUrl {
query_id: QueryId,
url: Uri,
url: String,
},
Inline {
query_id: QueryId,
Expand All @@ -197,20 +196,23 @@ pub enum QueryInput {
}

impl QueryInput {
#[must_use]
pub fn query_id(&self) -> QueryId {
match self {
Self::FromUrl { query_id, .. } | Self::Inline { query_id, .. } => *query_id,
}
}

#[must_use]
pub fn input_stream(self) -> Option<BodyStream> {
match self {
Self::Inline { input_stream, .. } => Some(input_stream),
Self::FromUrl { .. } => None,
}
}

pub fn url(&self) -> Option<&Uri> {
#[must_use]
pub fn url(&self) -> Option<&str> {
match self {
Self::FromUrl { url, .. } => Some(url),
Self::Inline { .. } => None,
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/net/http_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ pub mod query {
self.query_input.query_id().as_ref(),
))
.build()?;
let query_input_url = self.query_input.url().cloned();
let query_input_url = self.query_input.url().map(ToOwned::to_owned);
let body = self
.query_input
.input_stream()
Expand All @@ -365,7 +365,7 @@ pub mod query {
if let Some(url) = query_input_url {
request.headers_mut().unwrap().insert(
&HTTP_QUERY_INPUT_URL_HEADER,
HeaderValue::try_from(url.to_string()).unwrap(),
HeaderValue::try_from(url).unwrap(),
);
}
Ok(request.body(body)?)
Expand Down
4 changes: 1 addition & 3 deletions ipa-core/src/net/server/handlers/query/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ mod tests {
"http://localhost:{}{}/{QUERY_ID}/input",
addr.to_ip().unwrap().port(),
http_serde::query::BASE_AXUM_PATH,
)
.parse()
.unwrap();
);
let req = http_serde::query::input::Request::new(QueryInput::FromUrl {
query_id: QUERY_ID,
url,
Expand Down

0 comments on commit fda46a0

Please sign in to comment.