perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.65k stars 1.56k forks source link

Hello World seems not to work with groovy script #946

Open KIC opened 6 years ago

KIC commented 6 years ago

Simply copy paste this script into a groovy file

import groovy.json.JsonOutput

@Grab(group='com.sparkjava', module='spark-core', version='2.7.1')
import static spark.Spark.*

get("/hello", {req, res ->
    println("dasdas")
    return JsonOutput.toJson([lala:12])
})

while I can see the printed dasdas I can not see any return of the callback function.

jakaarl commented 6 years ago

Confirmed not to work. My first hunch was that a GString is returned instead of a java.lang.String and that would confuse Spark, but turned out that's not the case. Needs to be looked into.

KIC commented 6 years ago

Ok, thanks for the feedback. I really like this Flask like api and would like to use it via groovy scripts.

KIC commented 6 years ago

It seems to work with groovy 2.5.0-beta2