Last active
October 19, 2022 18:18
-
-
Save berndruecker/48176bc20b576381963b21d26dc7975f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Part of the runtime that provides webhook endpoints | |
@PostMapping("/inbound/{context}") | |
public ResponseEntity<ProcessInstanceEvent> inbound( | |
@PathVariable String context, | |
@RequestBody Map<String, Object> body, | |
@RequestHeader Map<String, String> headers) { | |
if (!registry.containsContextPath(context)) { | |
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "No webhook found for context: " + context); | |
} | |
WebhookConnectorProperties connectorProperties = registry.getWebhookConnectorByContextPath(context); | |
boolean valid = validateSecret(connectorProperties, webhookContext); | |
if (!valid) { | |
return ResponseEntity.status(400).build(); | |
} | |
Map<String, Object> variables = extractVariables(connectorProperties, webhookContext); | |
ProcessInstanceEvent processInstanceEvent = zeebeClient | |
.newCreateInstanceCommand() | |
.bpmnProcessId(connectorProperties.bpmnProcessId()) | |
.version(connectorProperties.version()) | |
.variables(variables) | |
.send() | |
.join(); // TODO: Switch to rective HTTP client | |
return ResponseEntity.status(HttpStatus.CREATED).body(processInstanceEvent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment