Hildebrandt Tobias
03/06/2024, 12:23 PMEndpoints
in my Multiplatform Project so that both js and jvm are always on the same page.
For readability I have a singleton that just holds all the references to the actual Endpoints
.
Is there a more idiomatic way in general to do this or is this fine?
Endpoints.kt
object Endpoints {
// Keycloak
val keyCloakNewToken = _keyCloakNewToken
val keyCloakRefreshToken = _keyCloakRefreshToken
val keyCloakUsers = _keyCloakUsers
// Server
val devices = _devices
val changeDevice = _changeDevice
}
KeyCloakEndpoints.kt
val _keyCloakUsers = Endpoint(
url = "/admin/realms/<realm>/users",
method = EndpointMethod.GET,
serializer = ArraySerializer(KeycloakUser.serializer())
)
val _keyCloakRefreshToken = Endpoint(
url = "/realms/<realm>/protocol/openid-connect/token",
method = <http://EndpointMethod.POST|EndpointMethod.POST>,
serializer = AuthJwt.serializer(),
header = mapOf(
"Content-Type" to "application/x-www-form-urlencoded"
),
requiredUrlEncodedBody = mapOf(
"grant_type" to "refresh_token",
"client_id" to "frontend",
"refresh_token" to ""
)
)
I read that only private Backingfields should start with an underscore, but I can't make them private here of course.Hildebrandt Tobias
03/06/2024, 12:25 PMEndpoints
in an Singleton as well and avoid the underscore thing alltogether. Something, something, tree, forest.