Skip to content

Commit 0f54003

Browse files
committed
Create configuration property for the HTTP path of the route that listens for webhook events
1 parent ebb8e61 commit 0f54003

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

docs/modules/ROOT/pages/includes/quarkus-github-app.adoc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,25 @@ endif::add-copy-button-to-env-var[]
8585
|
8686

8787

88+
a| [[quarkus-github-app_quarkus-github-app-webhook-url-path]]`link:#quarkus-github-app_quarkus-github-app-webhook-url-path[quarkus.github-app.webhook-url-path]`
89+
90+
91+
[.description]
92+
--
93+
The webhook URL path that the GitHub App listens to, prefixed with the "/" character.
94+
95+
This defaults to the root "/" but could be configured to a something else to enable deployment alongside other HTTP routes. such as "/github-event"
96+
97+
ifdef::add-copy-button-to-env-var[]
98+
Environment variable: env_var_with_copy_button:+++QUARKUS_GITHUB_APP_WEBHOOK_URL_PATH+++[]
99+
endif::add-copy-button-to-env-var[]
100+
ifndef::add-copy-button-to-env-var[]
101+
Environment variable: `+++QUARKUS_GITHUB_APP_WEBHOOK_URL_PATH+++`
102+
endif::add-copy-button-to-env-var[]
103+
--|string
104+
|`/`
105+
106+
88107
a| [[quarkus-github-app_quarkus-github-app-webhook-secret]]`link:#quarkus-github-app_quarkus-github-app-webhook-secret[quarkus.github-app.webhook-secret]`
89108

90109

runtime/src/main/java/io/quarkiverse/githubapp/runtime/Routes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void init(@Observes StartupEvent startupEvent) throws IOException {
7373
}
7474

7575
public void init(@Observes Router router) {
76-
router.post("/")
76+
router.post(checkedConfigProvider.webhookUrlPath())
7777
.handler(BodyHandler.create()) // this is required so that the body to be read by subsequent handlers
7878
.blockingHandler(routingContext -> {
7979
try {

runtime/src/main/java/io/quarkiverse/githubapp/runtime/config/CheckedConfigProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ public String restApiEndpoint() {
108108
return gitHubAppRuntimeConfig.restApiEndpoint;
109109
}
110110

111+
public String webhookUrlPath() {
112+
return gitHubAppRuntimeConfig.webhookUrlPath;
113+
}
114+
111115
public String graphqlApiEndpoint() {
112116
return gitHubAppRuntimeConfig.graphqlApiEndpoint;
113117
}

runtime/src/main/java/io/quarkiverse/githubapp/runtime/config/GitHubAppRuntimeConfig.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ public class GitHubAppRuntimeConfig {
4646
@ConvertWith(PrivateKeyConverter.class)
4747
Optional<PrivateKey> privateKey;
4848

49+
/**
50+
* The webhook URL path that the GitHub App listens to, prefixed with the "/" character.
51+
* <p>
52+
* This defaults to the root "/" but could be configured to a something else to enable deployment alongside other HTTP
53+
* routes. such as "/github-event"
54+
*/
55+
@ConfigItem(defaultValue = "/")
56+
String webhookUrlPath;
57+
4958
/**
5059
* The webhook secret if defined in the GitHub UI.
5160
*/

runtime/src/main/java/io/quarkiverse/githubapp/runtime/smee/SmeeIoForwarder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public class SmeeIoForwarder {
5050

5151
LOG.info("Listening to events coming from " + checkedConfigProvider.webhookProxyUrl().get());
5252

53-
URI localUrl = URI.create("http://" + httpConfiguration.host + ":" + httpConfiguration.port + "/");
53+
URI localUrl = URI.create(
54+
"http://" + httpConfiguration.host + ":" + httpConfiguration.port + checkedConfigProvider.webhookUrlPath());
5455

5556
this.replayEventStreamAdapter = new ReplayEventStreamAdapter(checkedConfigProvider.webhookProxyUrl().get(), localUrl,
5657
objectMapper);

0 commit comments

Comments
 (0)