This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user