mutate
Creates a new instance of HttpResponse based on this object, using a Kotlin domain-specific language (DSL) builder.
This function provides a way to modify an existing HttpResponse using expressive, English-like syntax.
The current HttpResponse is converted to a builder, and then the init
lambda with HttpResponse.Builder as its receiver is applied. This allows the lambda to invoke the methods of HttpResponse.Builder without having to qualify them.
Example usage:
val newResponse = oldResponse.mutate {
code(404)
message("Not Found")
}
Content copied to clipboard
This example modifies the status code and message of the oldResponse
.
Return
the mutated HttpResponse.
Parameters
init
a lambda function where HttpResponse.Builder functions can be called.