Skip to content

Commit 6f1f903

Browse files
authored
Merge pull request #129 from ngrok/del/label-appProtocol
feat: add appProtocol + label support
2 parents 02476bd + fbbf904 commit 6f1f903

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

examples/ngrok-labeled.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ builder.connect().then((session) => {
2626
.labeledListener()
2727
.label("edge", "edghts_<edge_id>")
2828
.metadata("example listener metadata from nodejs")
29+
// Set the appProtocol for the listener, i.e. "http1" or "http2", default is "http1"
30+
// .appProtocol("http2")
2931
.listen()
3032
.then((listener) => {
3133
console.log("Ingress established at: " + JSON.stringify(listener.labels()));

index.d.ts

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/connect.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ async fn tls_endpoint(session: &Session, cfg: &Config) -> Result<String> {
282282
async fn labeled_listener(session: &Session, cfg: &Config) -> Result<String> {
283283
let mut bld = session.labeled_listener();
284284
plumb!(bld, cfg, metadata);
285+
plumb!(bld, cfg, app_protocol);
285286
plumb_vec!(bld, cfg, label, labels, ":");
286287
Ok(bld.listen(None).await?.id())
287288
}

src/listener_builder.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ macro_rules! make_listener_builder {
188188
builder.label(label, value);
189189
self
190190
}
191+
192+
/// Set the L7 application portocol for this listener, i.e. "http1" or "http2" (defaults "http1")
193+
#[napi]
194+
pub fn app_protocol(&mut self, app_protocol: String) -> &Self {
195+
let mut builder = self.listener_builder.lock();
196+
builder.app_protocol(app_protocol);
197+
self
198+
}
191199
}
192200
};
193201
}

0 commit comments

Comments
 (0)