Skip to content

Commit

Permalink
Merge pull request #101 from ngrok/feat/labeled-app_protocol
Browse files Browse the repository at this point in the history
add app_protocol to labeled listeners
  • Loading branch information
OfTheDelmer committed Mar 5, 2024
2 parents 696dedc + befbcb0 commit 2eb52dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/ngrok-labeled.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ async def create_listener() -> ngrok.Listener:
await session.labeled_listener()
.label("edge", "edghts_<edge_id>")
.metadata("example listener metadata from python")
# Set the application protocol to "http1" or "http2"
# .app_protocol("http2")
.listen()
)

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


Expand Down
1 change: 1 addition & 0 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ async fn labeled_listener(
let cfg = options.as_ref(py);
type B = LabeledListenerBuilder;
plumb!(B, bld, cfg, metadata);
plumb!(B, bld, cfg, app_protocol);
plumb_vec!(B, bld, cfg, label, labels, ":");
Ok::<_, PyErr>(bld.replace(session.labeled_listener()))
})?;
Expand Down
6 changes: 6 additions & 0 deletions src/listener_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ macro_rules! make_listener_builder {
self_.set(|b| {b.label(label, value);});
self_
}

/// Set the L7 application protocol used for this listener, i.e. "http1" or "http2" (default "http1")
pub fn app_protocol(self_: PyRefMut<Self>, app_protocol: String) -> PyRefMut<Self> {
self_.set(|b| {b.app_protocol(app_protocol);});
self_
}
}
};
}
Expand Down

0 comments on commit 2eb52dc

Please sign in to comment.