24 lines
594 B
Kotlin
24 lines
594 B
Kotlin
package be.simplenotes.app
|
|
|
|
import org.http4k.server.Http4kServer
|
|
import org.slf4j.LoggerFactory
|
|
import be.simplenotes.shared.config.ServerConfig as SimpleNotesServerConfig
|
|
|
|
class Server(
|
|
private val config: SimpleNotesServerConfig,
|
|
private val http4kServer: Http4kServer,
|
|
) {
|
|
private val logger = LoggerFactory.getLogger(javaClass)
|
|
|
|
fun start(): Server {
|
|
http4kServer.start()
|
|
logger.info("Listening on http://${config.host}:${config.port}")
|
|
return this
|
|
}
|
|
|
|
fun stop() {
|
|
logger.info("Stopping server")
|
|
http4kServer.close()
|
|
}
|
|
}
|