Created
July 28, 2020 21:13
-
-
Save mathias21/edc03421c477ad5a86538d90bc45d67e to your computer and use it in GitHub Desktop.
KtorEasy route definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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