HTTP.kt 746 B

1234567891011121314151617181920212223242526
  1. package ru.mephi.plugins
  2. import io.ktor.features.*
  3. import io.ktor.http.content.*
  4. import io.ktor.http.*
  5. import io.ktor.application.*
  6. import io.ktor.response.*
  7. import io.ktor.request.*
  8. fun Application.configureHTTP() {
  9. install(CachingHeaders) {
  10. options { outgoingContent ->
  11. when (outgoingContent.contentType?.withoutParameters()) {
  12. ContentType.Text.CSS -> CachingOptions(CacheControl.MaxAge(maxAgeSeconds = 24 * 60 * 60))
  13. else -> null
  14. }
  15. }
  16. }
  17. install(HttpsRedirect) {
  18. // The port to redirect to. By default 443, the default HTTPS port.
  19. sslPort = 443
  20. // 301 Moved Permanently, or 302 Found redirect.
  21. permanentRedirect = true
  22. }
  23. }