Provides a Http4k Filter for intercepting http requests and responses and adding the details to the provided lsdContext instance.
- Add dependencies
implementation 'io.github.lsd-consulting:lsd-core:<version>'
implementation 'io.github.lsd-consulting:lsd-interceptors-http4k:<version>'
- Configure an interceptor with an LsdContext
// Obtain an instance of an LsdContext
private val lsd = LsdContext.instance
// Pass the lsdContext instance to the filter provider (along with any additional options)
private val lsdFilter = LsdFilterProvider(lsd).filter
- Include the filter in the filter chain for your application handler e.g.
val app = lsdFilter.then(appHandler)
-
Invoke your application with requests, e.g. via tests
- By default
User-Agent
header is used to determine the source participant name - By default
Host
header is used to determine the target participant name - You can override these when instantiating the LsdFilterProvider class by overriding the
sourceNameProvider
ortargetNameProvider
to use alternative headers or anything else available in theRequest
- By default
-
Generate the report:
// You can capture multiple scenarios within a report
lsd.completeScenario("scenario title")
// Finally created the report
lsd.completeReport("report title")
For a contrived example, see file ExampleWithReportGenerated.kt
which was used to generate the below report. Each arrow can be clicked to reveal the headers and body of each request and response:
See lsd-core project for further details on how the reports with sequence diagrams can be generated.