Here’s a small example: ``` package app import f...
# ktor
r
Here’s a small example:
Copy code
package 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")))
        }
    }
}
j
Thanks it's easier than I was making it out to be.
r
Same here 🙂