aesteve / nubes

Annotation layer on top of Vert.x 3
Apache License 2.0
120 stars 35 forks source link

Session object #67

Closed FunnyDevs closed 7 years ago

FunnyDevs commented 7 years ago

I have tried to access Session object (even adding SessionHandler.create), but is always null. How is possibile???

aesteve commented 7 years ago

Can you show me some code of yours ?

This should work, there's even a unit test checking that when you access the session objet from within a controller method it should not be null.

See : https://github.com/aesteve/nubes/blob/master/src/test/java/integration/session/SessionSpec.java relying on https://github.com/aesteve/nubes/blob/master/src/test/java/mock/controllers/session/SessionAwareController.java

FunnyDevs commented 7 years ago

I used routingContext.session() to get session, and it returned null value. But if i use (RoutingContext routingContext,Session session) as method sign, session is not null (even if i call it with routingContext.session() inside method)

Thank you

aesteve commented 7 years ago

Ah OK I see.

Yes, if you declare the session in your method, Nubes automatically adds the SessionHandler to your route, so that Session will never be null.

I'm very interested in every remark you could have in the future, please do not hesitate to open issues just to tell me what you'd like as improvements, and what you're thinking about the framework overall.