Robert Menke
04/10/2018, 2:46 AMpackage app
import freemarker.cache.ClassTemplateLoader
import io.ktor.application.*
import io.ktor.features.CallLogging
import io.ktor.features.DefaultHeaders
import io.ktor.freemarker.FreeMarker
import io.ktor.freemarker.FreeMarkerContent
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.sessions.Sessions
import io.ktor.sessions.cookie
import io.ktor.websocket.WebSockets
import session.AuthenticatedSession
import sockets.SecureSocketServer
import java.time.Duration
fun Application.main() {
install(DefaultHeaders)
install(CallLogging)
//<https://ktor.io/features/sessions.html#install-basic>
install(Sessions) {
cookie<AuthenticatedSession>(AuthenticatedSession.NAME)
}
//<https://ktor.io/features/freemarker.html>
install(FreeMarker) {
templateLoader = ClassTemplateLoader(Application::class.java.classLoader, "templates")
}
//<https://ktor.io/features/routing.html>
routing()
}
fun Application.routing() {
install(Routing) {
get("/") {
call.respond(FreeMarkerContent("index.ftl", mapOf("test_name" to "World")))
}
}
}
jphillips
04/10/2018, 2:55 AMRobert Menke
04/10/2018, 3:05 AM