formatBody

fun formatBody(body: String?, contentType: ContentType = ContentType.Any): String(source)

Formats the HTTP request body, applying syntax highlighting if color output is enabled.

Returns an empty string if the body is null or blank. If color output is enabled, the body is highlighted according to its content type; otherwise, the raw body string is returned.

Return

The formatted body string, or an empty string if the body is null or blank.

Parameters

body

The HTTP request body to format.

contentType

The content type of the body, used for syntax highlighting.