Ryunos
11/25/2022, 3:38 PMdave
11/25/2022, 3:51 PMRyunos
11/25/2022, 3:59 PMoverride fun find(search: String?, roles: String?, customerAccountId: String?, limit: Int?): List<User> =
this.httpClient(
Request(Method.GET, "$baseUrl/users")
.query("search", search)
.query("roles", roles?.replace("DEMONSTRATION", "ANIMATOR"))
.query("limit", limit?.toString())
.let { if (customerAccountId !== null) it.query("customerAccountRef", customerAccountId) else it })
.takeIf { it.status == OK }
?.let(userListLens)
?.map { it.toDomain() }
?: listOf()
James Richardson
11/25/2022, 7:16 PMdave
11/26/2022, 11:33 AMfun <T : HttpMessage> BiDiLensSpec<T, String>.convert(from: Charset, to: Charset) =
map({ String(it.toByteArray(from), to) }, { String(it.toByteArray(from), to) })
val queryLens = Query.convert(UTF_8, ISO_8859_1).required("foo")
val headerLens = Header.convert(UTF_8, ISO_8859_1).required("bar")
Request(GET, "<http://someurl>").with(queryLens of "hello", headerLens of "world")
You can't globally override the charset in http4k, regardless of if it's with or against the spec 🙂Ryunos
11/28/2022, 8:39 AM