all routes wired together
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-04-05 11:14:02 +02:00
parent af4307c6a4
commit b5be06848e
9 changed files with 69 additions and 53 deletions

View File

@@ -13,9 +13,12 @@ import io.ktor.auth.*
import kotlin.reflect.*
import java.util.*
import org.apache.http.HttpException
import com.kmalbz.database.DatabaseFactory
import io.ktor.util.KtorExperimentalAPI
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
@KtorExperimentalAPI
@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
@@ -30,6 +33,8 @@ fun Application.module(testing: Boolean = false) {
install(Authentication) {
}
DatabaseFactory.init()
routing {
get("/") {
call.respondText("HELLO WORLD!", contentType = ContentType.Text.Plain)
@@ -40,15 +45,15 @@ fun Application.module(testing: Boolean = false) {
}
install(StatusPages) {
exception<AuthenticationException> { cause ->
exception<AuthenticationException> { _ ->
call.respond(HttpStatusCode.Unauthorized)
}
exception<AuthorizationException> { cause ->
exception<AuthorizationException> { _ ->
call.respond(HttpStatusCode.Forbidden)
}
exception<HttpException> { cause ->
exception<HttpException> { _ ->
call.respond(HttpStatusCode.BadRequest)
}
}