package dev.inmo.postssystem.server

import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
import io.ktor.application.call
import io.ktor.http.content.*
import io.ktor.response.respondRedirect
import io.ktor.routing.Route
import io.ktor.routing.get
import java.io.File

class ClientStaticRoutingConfiguration(
    private val clientStatic: String?
) : ApplicationRoutingConfigurator.Element {
    override fun Route.invoke() {
        clientStatic ?.let {
            static("client") {
                resources(it)
                get {
                    call.respondRedirect("client/index.html")
                }
            }
            get {
                call.respondRedirect("client")
            }
        }
    }
}
