headers
Creates a new HttpHeaders instance from a given builder lambda, using Kotlin DSL style.
This function allows for a more expressive, English-like syntax when creating an HttpHeaders instance. It accepts a lambda with HttpHeaders.Builder as its receiver, allowing the methods of HttpHeaders.Builder to be called within the lambda without qualifying them.
This function is part of a DSL (Domain-Specific Language), which allows for clearer and more concise code.
Example usage:
val headers = headers {
"Header1" to "value1"
add("Header2", "value2")
}
Content copied to clipboard
This example creates a new HttpHeaders instance with the specified headers.
Return
The constructed HttpHeaders instance.
Important: This is a Public Preview API. It may be changed or removed at any time.
Parameters
init
A builder lambda used to configure the HttpHeaders instance.