Http Formatter
open class HttpFormatter(theme: ColorTheme = ColorTheme.LIGHT_ON_DARK, useColor: Boolean = isColorSupported(), json: Json = DefaultJson)(source)
A utility class to format HTTP requests and responses into colorized strings for better readability.
This formatter applies syntax highlighting based on HTTP methods, headers, bodies, and status codes. It supports customizable color themes and enables or disables colorization depending on platform support.
Parameters
theme
The color theme to be applied for formatting.
use Color
Boolean flag indicating whether ANSI color codes should be used in the formatting output.
json
The Json instance used to encode typed response bodies for display. Should match the instance used by Ktor's ContentNegotiation so that custom kotlinx.serialization.modules.SerializersModule registrations are reflected in logs.
Constructors
Link copied to clipboard
constructor(theme: ColorTheme = ColorTheme.LIGHT_ON_DARK, useColor: Boolean = isColorSupported(), json: Json = DefaultJson)
Types
Link copied to clipboard
data class ColorScheme(val path: AnsiColor, val headerName: AnsiColor, val headerValue: AnsiColor, val body: AnsiColor)