Its possible to bind data between handlers in ratpack, but in once execution?

I'm developing a spring ratpack project, but I want to know if there is any way to bind data between handlers. I tried with registries but I can't find the way that the object only have a value in one execution. I tried to use ratpack session, but i don't want to generate a session cookie to persist that object onto my handlers. What should i do? I'm lost right now.

This is my code configuration and the way how I persist the objects:

<!-- language: java -->

    //persisting with the SessionModule
    ctx.get(Session.class).getData().then(d -> {
                d.set("email", email);
                ctx.next();
            });

    //Persisting with the registries
            ObjectRegistryComponent objectRegistryComponent = ctx.get(ObjectRegistryComponent.class);
            objectRegistryComponent.setObject(email);
            ctx.next(Registry.single(objectRegistryComponent));

Upvotes: 0

Views: 203

Answers (1)

I found something about the requests in ratpack, you can add registries to the requests, that solve my problem as well.

Request request = ctx.getRequest();
request.add(email);

//--- into your other handlers
String email = ctx.getRequest().get(String.class);

Upvotes: 0

Related Questions