Created
August 3, 2020 21:45
-
-
Save mathias21/ccc7da8966727c7cb13054b440a51de0 to your computer and use it in GitHub Desktop.
KtorEasy controller testing: controller's overview
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
class RegistrationControllerImp : BaseController(), RegistrationController, KoinComponent { | |
private val userApi by inject<UserApi>() | |
override suspend fun createUser(postUser: PostUserBody): ResponseUser { | |
val user = dbQuery { | |
userApi.getUserByUsername(postUser.username)?.let { | |
throw InvalidUserException("User is already taken") | |
} | |
userApi.createUser(postUser) ?: throw UnknownError("Internal server error") | |
} | |
return user.toResponseUser() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment