You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
csamsserver/src/Application.kt

47 lines
1.1 KiB

package com.gyf.csams
import io.ktor.application.*
import io.ktor.features.*
import io.ktor.gson.*
import io.ktor.http.*
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
install(CORS) {
method(HttpMethod.Options)
method(HttpMethod.Put)
method(HttpMethod.Delete)
method(HttpMethod.Patch)
header(HttpHeaders.Authorization)
header("MyCustomHeader")
allowCredentials = true
anyHost() // @TODO: Don't do this in production if possible. Try to limit it.
}
install(ContentNegotiation) {
gson()
}
install(CallLogging)
}
fun Application.Controller(testing: Boolean = false){
AccountController()
TestController()
MainController()
AssociationController()
NotificationController()
/**
* 初始化log
*/
listOf(MainService,AccountService,FileService,AssociationService,BackgroundService).forEach {
it.init(environment)
}
}