adding session module through the GroovyClosureHandlerFactory

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

adding session module through the GroovyClosureHandlerFactory

lennel
Not on my development machine, but I have not been able to figure out how to add bindings (specifically sessions) when using the GroovyClosureHandlerFactory, any pointers (or adding to the session documentation :) ) would be handy.
Reply | Threaded
Open this post in threaded view
|

Re: adding session module through the GroovyClosureHandlerFactory

uris77
Can you paste  some code? Or pseudo code of what you want to accomplish.
Reply | Threaded
Open this post in threaded view
|

Re: adding session module through the GroovyClosureHandlerFactory

Luke Daley
Administrator
In reply to this post by lennel
If you’re launching yourself, it would be something like this…

LaunchConfigBuilder.baseDir(«some base dir»).build(new GroovyClosureHandlerFactory({
  bindings {
    add new ratpack.session.SessionModule()
    add new ratpack.session.store.MapSessionsModule() // assuming you want this store implementation
  }
})
Reply | Threaded
Open this post in threaded view
|

Re: adding session module through the GroovyClosureHandlerFactory

Luke Daley
Administrator
In reply to this post by lennel
It strikes me now that you probably already have a closure, but you’re wanting to implicitly add the module. To do this you’d just join the closures…

def someOtherClosure = {}
LaunchConfigBuilder.baseDir(«some base dir»).build(new GroovyClosureHandlerFactory({
  bindings {
    add new ratpack.session.SessionModule()
    add new ratpack.session.store.MapSessionsModule() // assuming you want this store implementation
  } 

  delegate.with(someOtherClosure)
})