io.lsdconsulting.interceptors.rabbitmq.HtmlRenderer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lsd-interceptors Show documentation
Show all versions of lsd-interceptors Show documentation
Provides various interceptors to capture events for the lsd-core library to generate sequence diagrams
package io.lsdconsulting.interceptors.rabbitmq
import j2html.TagCreator
fun renderHtmlFor(messageHeaders: Map>, prettyBody: String?): String {
return TagCreator.div(
TagCreator.section(TagCreator.h3("Message Headers"), TagCreator.p(prettyPrintHeaders(messageHeaders))),
if (prettyBody.isNullOrEmpty()) TagCreator.p()
else TagCreator.section(
TagCreator.h3("Body"),
TagCreator.p(prettyBody)
)
).render()
}
private fun prettyPrintHeaders(requestHeaders: Map>): String =
requestHeaders.entries.joinToString(separator = System.lineSeparator()) { (key, value): Map.Entry -> "$key: $value" }
© 2015 - 2024 Weber Informatics LLC | Privacy Policy