All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.ktor.EncryptionEnforcementKtorPlugin.kt Maven / Gradle / Ivy

The newest version!
package io.fluidsonic.raptor.ktor

import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.plugins.*
import io.ktor.server.response.*


internal val EncryptionEnforcementKtorPlugin = createApplicationPlugin("Raptor: encryption enforcement") {
	onCall { call ->
		val scheme = call.request.origin.scheme
		if (scheme != "https" && scheme != "wss")
			call.respondText("The connection protocol is not secure.", status = HttpStatusCode.BadRequest)
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy