Skip to content

Instantly share code, notes, and snippets.

@skurfuerst
Created July 16, 2014 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skurfuerst/94c565cf848a40895dca to your computer and use it in GitHub Desktop.
Save skurfuerst/94c565cf848a40895dca to your computer and use it in GitHub Desktop.
def config = {
bindings {
add new SessionModule()
add new MapSessionsModule(10, 5)
}
handlers {
// ...
}
}
// Start up Ratpack
def properties = new Properties()
properties.setProperty('handlerFactory', 'my.namespace.http.DummyRatpackHandlerFactory')
properties.setProperty('port', '5050')
properties.setProperty('publicAddress', 'http://' + configurationManager.domainName + ':5050')
def baseLaunchConfiguration = LaunchConfigs.createFromGlobalProperties(this.class.classLoader, System.getProperties(), properties)
def finalLaunchConfiguration = new DelegatingLaunchConfig(baseLaunchConfiguration) {
@Override
public HandlerFactory getHandlerFactory() {
return new GroovyClosureHandlerFactory(config)
}
};
ratpackServer = RatpackServerBuilder.build(finalLaunchConfiguration)
ratpackServer.start()
/**
* This is a dummy class which we currently need for instanciating Ratpack and building a proper LaunchConfig. However, in production,
* this class is never used.
*/
class DummyRatpackHandlerFactory implements HandlerFactory {
@Override
Handler create(LaunchConfig launchConfig) throws Exception {
return null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment