A service to provide Slack-like unfurling.
Add it to your build.gradle
:
compile 'net.dinomite.web:unfurling:1.1.15'
Use it by creating an UnfurlingService
and asking it to unfurl()
a URI
:
val unfurlingService = UnfurlingService(HttpClients.createDefault())
val unfurled = unfurlingService.unfurl(URI("https://twitter.com/dinomite"))
println(unfurled.url) // https://twitter.com/dinomite
println(unfurled.title) // Rev. Drew Stephens
println(unfurled.image.url) // https://pbs.twimg.com/profile_images/1144814297/Drew_955x955.jpg
println(unfurled.description) // Grand High Figurehead, Church of Empirical Evidence
This module uses the Mapped Diagnostic Context (MDC) key "unfurling-uri" to
provide the URI for which failures occur. Add the MDC, %mdc
, to your logging pattern to see this information.