Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Update SSLConfig and StaticFilesPlugin to use new Ktor API
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek52 committed Sep 16, 2022
1 parent 02e1eae commit c9bede7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/main/kotlin/kweb/https/SSLConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import io.ktor.network.tls.extensions.HashAlgorithm
import io.ktor.network.tls.extensions.SignatureAlgorithm
import io.ktor.server.engine.ConnectorType
import io.ktor.server.engine.EngineSSLConnectorConfig
import io.ktor.util.KtorExperimentalAPI
import java.io.File
import java.security.KeyStore
import kotlin.text.toCharArray

@KtorExperimentalAPI
val defaultKeyStore by lazy {
buildKeyStore {
certificate("test") {
Expand All @@ -27,7 +26,9 @@ data class SSLConfig constructor(
override val keyStorePath: File? = null,
override val keyAlias: String = "mykey",
override val keyStorePassword: () -> CharArray = { "changeit".toCharArray() },
override val privateKeyPassword: () -> CharArray = { "changeit".toCharArray() }
override val privateKeyPassword: () -> CharArray = { "changeit".toCharArray() },
override val trustStore: KeyStore? = null,
override val trustStorePath: File? = null
) : EngineSSLConnectorConfig {
override val type: ConnectorType = ConnectorType.HTTPS
}
5 changes: 3 additions & 2 deletions src/main/kotlin/kweb/plugins/staticFiles/StaticFilesPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package kweb.plugins.staticFiles

import io.ktor.server.application.install
import io.ktor.server.plugins.CachingHeaders
import io.ktor.server.plugins.cachingheaders.*
import io.ktor.http.CacheControl
import io.ktor.http.content.*
import io.ktor.server.http.content.*
import io.ktor.server.routing.Route
import io.ktor.server.routing.Routing
import kweb.plugins.KwebPlugin
Expand Down Expand Up @@ -42,7 +43,7 @@ class StaticFilesPlugin private constructor(private val servedRoute: String, pri
TODO: so that we can set a very long cache time (> 1 year). For now it defaults
TODO: to one hour.
*/
options {
options { call, content ->
CachingOptions(CacheControl.MaxAge(maxAgeSeconds = maxCacheAgeSeconds))
}
}
Expand Down

0 comments on commit c9bede7

Please sign in to comment.