30 lines
1.1 KiB
Kotlin
30 lines
1.1 KiB
Kotlin
|
package com.cubetiqs.web.config
|
||
|
|
||
|
import org.apache.catalina.connector.Connector
|
||
|
import org.springframework.beans.factory.annotation.Value
|
||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
|
||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory
|
||
|
import org.springframework.context.annotation.Bean
|
||
|
import org.springframework.context.annotation.Configuration
|
||
|
|
||
|
@ConditionalOnProperty(name = ["http.port"], matchIfMissing = false)
|
||
|
@Configuration
|
||
|
class HttpServletConfig(
|
||
|
@Value("\${http.port:8080}")
|
||
|
private val httpPort: Int,
|
||
|
) {
|
||
|
@Bean
|
||
|
fun servletContainer(): ServletWebServerFactory {
|
||
|
val tomcat = TomcatServletWebServerFactory()
|
||
|
tomcat.addAdditionalTomcatConnectors(createStandardConnector())
|
||
|
return tomcat
|
||
|
}
|
||
|
|
||
|
private fun createStandardConnector(): Connector {
|
||
|
val connector = Connector("org.apache.coyote.http11.Http11NioProtocol")
|
||
|
connector.port = httpPort
|
||
|
connector.scheme = "http"
|
||
|
return connector
|
||
|
}
|
||
|
}
|