Merge branch 'stable-2.15'
* stable-2.15:
Update bazlets to the latest on stable-2.14 to use 2.14.7 release API
Include canonicalWebURL in X-Origin-Url header in POST requests
Change-Id: I7860439ce6d92a7590586d559c2bb0be722ec8b5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/processors/GerritEventProcessor.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/processors/GerritEventProcessor.java
index e9c373c..1a8d6d0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/processors/GerritEventProcessor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/processors/GerritEventProcessor.java
@@ -15,10 +15,13 @@
package com.googlesource.gerrit.plugins.webhooks.processors;
import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.events.ProjectEvent;
import com.google.gerrit.server.events.SupplierSerializer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.webhooks.EventProcessor;
import com.googlesource.gerrit.plugins.webhooks.RemoteConfig;
import java.util.Optional;
@@ -27,8 +30,17 @@
private static Gson GSON =
new GsonBuilder().registerTypeAdapter(Supplier.class, new SupplierSerializer()).create();
+ private final String canonicalWebUrl;
+
+ @Inject
+ GerritEventProcessor(@CanonicalWebUrl String canonicalWebUrl) {
+ this.canonicalWebUrl = canonicalWebUrl;
+ }
+
@Override
public Optional<EventProcessor.Request> doProcess(ProjectEvent event, RemoteConfig remote) {
- return Optional.of(new EventProcessor.Request(GSON.toJson(event)));
+ return Optional.of(
+ new EventProcessor.Request(
+ GSON.toJson(event), ImmutableMap.of("X-Origin-Url", canonicalWebUrl)));
}
}