paul
paul

Reputation: 13471

Start ratpack.groovy from Java

I´m trying to use ratpack groovy framework from Java, but I cannot find a way to init from Java.

Any idea how to start up a ratpack.groovy script from Java?

This is my ratpack script

 ratpack {
def tokens=[:]
serverConfig {
    port 9000
}
handlers {
    get("identity/:token") {
        def token= pathTokens["token"]
        render tokens[token]
    }
}
}

Regards.

Upvotes: 0

Views: 183

Answers (1)

davidmc24
davidmc24

Reputation: 2282

Based on GroovyRatpackMain, you can start a Groovy app from Java like this:

import ratpack.server.RatpackServer;

RatpackServer.start(Groovy.Script.appWithArgs(args));

If you need to use a non-default script file or perform other customization, Groovy.Script has methods to support that.

Upvotes: 2

Related Questions