perwendel / spark-kotlin

A Spark DSL in idiomatic kotlin // dependency: com.sparkjava:spark-kotlin:1.0.0-alpha
Apache License 2.0
988 stars 43 forks source link

Too many arguments for public fun ignite() #34

Closed matths closed 6 years ago

matths commented 6 years ago

Hi! I try to run the basic example given on the project main page:

val http = ignite {
    port = 8080
    ipAddress = "0.0.0.0"
    threadPool {
        maxThreads = 10
        minThreads = 5
        idleTimeoutMillis = 1000
    }
}

http.get("/") {
    "Hello Spark Kotlin!"
}

but it gives already errors without doing a compile/build step, saying "Too many arguments for public fun ignite()". I would appreciate a working example or some hint, what goes wrong.

I added import spark.kotlin.* to the import section of my main.kt file and implementation "com.sparkjava:spark-kotlin:1.0.0-alpha" to my modules build.gradle dependencies section. And yes I triggered a gradle sync afterwards.

matths commented 6 years ago

Nevermind. I eventually found the documentation on the website and changed syntax into

       val http = ignite()

        http.port(8080)
        http.ipAddress("0.0.0.0")

        val maxThreads = 8
        val minThreads = 2
        val timeOutMillis = 30000
        http.threadPool(maxThreads, minThreads, timeOutMillis)

        http.get("/") {
            "Hello Spark Kotlin!"
        }

Now that it's compiling, I get runtime error saying it needs functionalities from above API 24. AS I need to support API 21 (Android 5.0 Lollipop), I can't use Spark in the project. Any recommendation what to use for an embedded webserver that is able to do https.