Skip to content

Instantly share code, notes, and snippets.

@mathias21
Created July 28, 2020 21:13
Show Gist options
  • Save mathias21/edc03421c477ad5a86538d90bc45d67e to your computer and use it in GitHub Desktop.
Save mathias21/edc03421c477ad5a86538d90bc45d67e to your computer and use it in GitHub Desktop.
KtorEasy route definition
fun Routing.registrationModule() {
val unauthenticatedController by inject<RegistrationController>()
post("user") {
val postUser = call.receive<PostUserBody>()
val user = unauthenticatedController.createUser(postUser)
call.respond(user)
}
post("authenticate") {
val credentials = call.receive<LoginCredentials>()
val loginTokenResponse = unauthenticatedController.authenticate(credentials)
call.respond(loginTokenResponse)
}
post("token") {
val credentials = call.receive<RefreshBody>()
val credentialsResponse = unauthenticatedController.refreshToken(credentials)
call.respond(credentialsResponse)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment