This commit is contained in:
@@ -9,9 +9,6 @@ import io.ktor.routing.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.gson.*
|
||||
import io.ktor.features.*
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.apache.*
|
||||
import io.ktor.auth.*
|
||||
import org.apache.http.HttpException
|
||||
import com.kmalbz.database.DatabaseFactory
|
||||
import com.kmalbz.database.dao.ResultObjects
|
||||
@@ -31,19 +28,12 @@ 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) {
|
||||
fun Application.module() {
|
||||
install(ContentNegotiation) {
|
||||
gson {
|
||||
}
|
||||
}
|
||||
|
||||
val client = HttpClient(Apache) {
|
||||
}
|
||||
|
||||
install(Authentication) {
|
||||
}
|
||||
|
||||
DatabaseFactory.init()
|
||||
transaction{
|
||||
SchemaUtils.create(ResultObjects)
|
||||
@@ -82,19 +72,19 @@ fun Application.module(testing: Boolean = false) {
|
||||
|
||||
routing {
|
||||
install(StatusPages) {
|
||||
exception<AuthenticationException> { _ ->
|
||||
exception<AuthenticationException> {
|
||||
call.respond(HttpStatusCode.Unauthorized)
|
||||
}
|
||||
|
||||
exception<AuthorizationException> { _ ->
|
||||
exception<AuthorizationException> {
|
||||
call.respond(HttpStatusCode.Forbidden)
|
||||
}
|
||||
|
||||
exception<HttpException> { _ ->
|
||||
exception<HttpException> {
|
||||
call.respond(HttpStatusCode.BadRequest)
|
||||
}
|
||||
|
||||
exception<IllegalStateException> { _ ->
|
||||
exception<IllegalStateException> {
|
||||
call.respond(HttpStatusCode.NotAcceptable)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user