Skip to content

Commit befbcb0

Browse files
committed
feat: add app_protocol to labeled listeners
1 parent 696dedc commit befbcb0

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

examples/ngrok-labeled.py

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ async def create_listener() -> ngrok.Listener:
1919
await session.labeled_listener()
2020
.label("edge", "edghts_<edge_id>")
2121
.metadata("example listener metadata from python")
22+
# Set the application protocol to "http1" or "http2"
23+
# .app_protocol("http2")
2224
.listen()
2325
)
2426

@@ -32,6 +34,8 @@ def create_listener_connect(addr):
3234
authtoken_from_env=True,
3335
labels="edge:edghts_<edge_id>",
3436
proto="labeled",
37+
# Set the application protocol to "http1" or "http2"
38+
# app_protocol="http2",
3539
)
3640

3741

src/connect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ async fn labeled_listener(
415415
let cfg = options.as_ref(py);
416416
type B = LabeledListenerBuilder;
417417
plumb!(B, bld, cfg, metadata);
418+
plumb!(B, bld, cfg, app_protocol);
418419
plumb_vec!(B, bld, cfg, label, labels, ":");
419420
Ok::<_, PyErr>(bld.replace(session.labeled_listener()))
420421
})?;

src/listener_builder.rs

+6
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ macro_rules! make_listener_builder {
231231
self_.set(|b| {b.label(label, value);});
232232
self_
233233
}
234+
235+
/// Set the L7 application protocol used for this listener, i.e. "http1" or "http2" (default "http1")
236+
pub fn app_protocol(self_: PyRefMut<Self>, app_protocol: String) -> PyRefMut<Self> {
237+
self_.set(|b| {b.app_protocol(app_protocol);});
238+
self_
239+
}
234240
}
235241
};
236242
}

0 commit comments

Comments
 (0)