Skip to content

Instantly share code, notes, and snippets.

@danveloper
Last active October 11, 2018 18:11
Show Gist options
  • Save danveloper/caddcf72c79025be4f60 to your computer and use it in GitHub Desktop.
Save danveloper/caddcf72c79025be4f60 to your computer and use it in GitHub Desktop.
Standalone Ratpack Groovy 0.9.13
@GrabResolver(name='netty', root='http://clinker.netty.io/nexus/content/repositories/snapshots')
@Grab('io.ratpack:ratpack-groovy:0.9.13-SNAPSHOT')
import ratpack.handling.Handler
import ratpack.server.*
RatpackServer.of { spec -> spec
.config(ServerConfig.noBaseDir())
.handler {
{ ctx -> ctx.render "Hello World!" } as Handler
}
} start()
@GrabResolver(name='netty', root='http://clinker.netty.io/nexus/content/repositories/snapshots')
@Grab('io.ratpack:ratpack-groovy:0.9.13-SNAPSHOT')
import ratpack.handling.Handler
import ratpack.server.*
Handler base = { ctx ->
ctx.render "Hello World!"
}
RatpackServer.of { spec -> spec
.config(ServerConfig.noBaseDir())
.handler { base }
} start()
@GrabResolver(name='netty', root='http://clinker.netty.io/nexus/content/repositories/snapshots')
@Grab('io.ratpack:ratpack-groovy:0.9.13-SNAPSHOT')
import ratpack.handling.Handler
import ratpack.server.*
Handler base = { ctx -> ctx.render "Hello World!" }
Handler route = { ctx -> ctx.render "Welcome $ctx.pathTokens.name!" }
RatpackServer.of { spec -> spec
.config(ServerConfig.noBaseDir())
.handlers { chain -> chain
.get(":name", route)
.get(base)
}
} start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment