bdawg.io
08/02/2018, 10:15 PMrequest
, but I’m trying to build and write them as a respond
orangy
orangy
Accept: application/x-www-form-urlencoded
of coursebdawg.io
08/02/2018, 10:27 PMcall.respond(object : OutgoingContent.ByteArrayContent() {
override val contentType get() = ContentType.Application.FormUrlEncoded
override fun bytes(): ByteArray =
mapOf(
"error" to "invalid_request",
"error_description" to "client_id was not valid"
)
.map { "${it.key}=${it.value}" }
.joinToString(separator = "&")
.toByteArray()
})
orangy
orangy
fun List<Pair<String, String?>>.formUrlEncode(): String
orangy
fun Parameters.formUrlEncode(): String
orangy
body = parametersOf("a", "1").formUrlEncode()
orangy
parametersOf(
"error" to "invalid_request",
"error_description" to "client_id was not valid"
).formUrlEncode()
bdawg.io
08/02/2018, 10:49 PMoverride fun bytes(): ByteArray = parametersOf(
"error" to listOf("invalid_request"),
"error_description" to listOf("client_id was not valid")
).formUrlEncode().toByteArray()
orangy
formUrlEncode
returns a String, and String will automatically be sent as bytes, you don’t need custom OutgoingContentorangy
respondUrlEncoded
which will have similar signature to parametersOf
and encode themorangy
call.respondUrlEncoded(
"error" to listOf("invalid_request"),
"error_description" to listOf("client_id was not valid")
)
bdawg.io
08/02/2018, 11:11 PMParameters
so it would abstract where they were received from and it doesn’t seem to add much at the call site call.respondUrlEncoded(parametersOf(
"error" to listOf("invalid_request"),
"error_description" to listOf("client_id was not valid")
))
orangy