Bernhard
07/21/2026, 9:43 AMAleksei Tirman [JB]
07/21/2026, 11:21 AMBernhard
07/21/2026, 11:22 AMclass OrchestrationEngineEventClient(
val secret: String,
val client: HttpClient,
val eventEndpointUrl: String,
val source: String,
) {
suspend fun <T : Any> publish(event: OrchestrationEngineEvent<T>): HttpResponse {
return client.post(eventEndpointUrl) {
accept(ContentType.Any)
setBody(event.payload, event.typeInfo)
contentType(ContentType.Application.Json)
header("ce-source", source)
header("ce-id", event.id)
header("ce-type", event.type)
header("ce-specversion", "1.0")
beforeRequest { request ->
val body = request.body as TextContent
val hmac = hmacSignatureB64(secret, body.text)
val b64Hmac = Base64.encode(hmac)
request.headers.append("x-emporix-hmac", b64Hmac)
}
}
}
}
fun HttpClient.registerBeforeRequest() {
plugin(HttpSend).intercept {
it.attributes
.getOrNull(AttributeKey<(HttpRequestBuilder) -> Unit>("beforeRequest"))
?.invoke(it)
execute(it)
}
}
fun HttpRequestBuilder.beforeRequest(callback: (HttpRequestBuilder) -> Unit) =
attributes.put(AttributeKey<(HttpRequestBuilder) -> Unit>("beforeRequest"), callback)Bernhard
07/21/2026, 11:23 AMBernhard
07/21/2026, 11:24 AMBernhard
07/21/2026, 11:25 AM[TYPEOF_SUSPEND_TYPE] Suspend functional types are not supported in typeOfBernhard
07/21/2026, 11:26 AMBernhard
07/21/2026, 11:28 AMAleksei Tirman [JB]
07/21/2026, 11:29 AMbeforeRequest handler for each request?Bernhard
07/21/2026, 11:29 AMBernhard
07/21/2026, 11:30 AMBernhard
07/21/2026, 11:30 AMAleksei Tirman [JB]
07/21/2026, 11:31 AMBernhard
07/21/2026, 11:31 AMAleksei Tirman [JB]
07/21/2026, 11:32 AMAleksei Tirman [JB]
07/21/2026, 11:34 AMBernhard
07/21/2026, 11:35 AMBernhard
07/21/2026, 11:35 AM