DanielZ
09/12/2023, 8:01 PMEnvironmentKey.uri().of().required()
to use the Uri
later in ClientFilters.SetHostFrom()
.
When I make the client call I run into the situation that I receive the error that schema
is not a valid http(s)
schema.
Is there an elegant way to ensure that the Uri
contains a valid schema? One option which came into my mind was using map
in the lens, which didn’t felt nicely.
Do you have some other ideas / advices?Andrew O'Hara
09/12/2023, 8:35 PMvalues4k
, you can make a custom value type that requires the scheme to be present.
class Url(value: Uri): AbstractValue<Uri>(value) {
companion object: ValueFactory<Url, Uri>(
coerceFn = ::Url,
parseFn = Uri::of,
validation = {it.scheme.isNotEmpty() }
)
}
val key = EnvironmentKey.value(Url).required("my_url")
DanielZ
09/13/2023, 5:40 AMvalues4k
create my own Uri
class which is doing all the validation. In addition I have then to create my own lenses.Andrew O'Hara
09/13/2023, 1:13 PM