Skip to content

Commit

Permalink
runtimes/core: handle handshake request with only path params (#1368)
Browse files Browse the repository at this point in the history
Handles handshake data with only path parameters
  • Loading branch information
fredr authored Sep 4, 2024
1 parent 3d0efe2 commit 8d326db
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion runtimes/core/src/api/schema/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ pub fn handshake_encoding(
meta: &meta::Data,
rpc: &meta::Rpc,
) -> anyhow::Result<Option<ReqSchemaUnderConstruction>> {
if !rpc.streaming_request && !rpc.streaming_response {
return Ok(None);
}

let default_path = meta::Path {
segments: vec![meta::PathSegment {
value: format!("{}.{}", rpc.service_name, rpc.name),
Expand All @@ -375,7 +379,25 @@ pub fn handshake_encoding(
let rpc_path = rpc.path.as_ref().unwrap_or(&default_path);

let Some(handshake_schema) = &rpc.handshake_schema else {
return Ok(None);
let has_dynamic_segments = rpc_path
.segments
.iter()
.any(|segment| segment.r#type() != SegmentType::Literal);

if !has_dynamic_segments {
return Ok(None);
}

return Ok(Some(ReqSchemaUnderConstruction {
methods: vec![Method::GET],
schema: SchemaUnderConstruction {
combined: None,
body: None,
query: None,
header: None,
rpc_path: Some(rpc_path.clone()),
},
}));
};

let mut config = EncodingConfig {
Expand Down

0 comments on commit 8d326db

Please sign in to comment.