Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing Spring Beans when using Pebble with WebFlux #512

Closed
huw0 opened this issue May 17, 2020 · 4 comments · Fixed by #513
Closed

Accessing Spring Beans when using Pebble with WebFlux #512

huw0 opened this issue May 17, 2020 · 4 comments · Fixed by #513
Milestone

Comments

@huw0
Copy link
Contributor

huw0 commented May 17, 2020

I'm using Spring Boot 2.3.0 with WebFlux and Pebble Spring Boot Starter 3.1.3.

As in the documentation I am attempting to access a Spring Bean using:

{{ beans.beanName }}

However this results in a stacktrace because the beans variable is not defined.

  • The header of Beans.java makes reference to being only for Spring MVC
  • It looks like the Beans object is only set within PebbleView and not PebbleReactiveView?
  1. I've made this work locally by extending PebbleReactiveView to set this object. Is this an acceptable fix? Possibly this was not done originally to prevent blocking methods being called?
  2. If this is intentional, I suggest amending the documentation to highlight that this is not available when using Pebble with WebFlux.
@ebussieres
Copy link
Member

It's not intentional and has been forgotten. Reactive support is kind of new in Pebble. You can make a PR if you wish to fix this issue. Otherwise, I'll take a look at it

@ebussieres ebussieres added this to the 3.1.4 milestone May 17, 2020
@huw0
Copy link
Contributor Author

huw0 commented May 17, 2020

Thanks for your quick response. I will try and tidy up what I have in the next few days and open a PR.

@ebussieres ebussieres linked a pull request May 17, 2020 that will close this issue
@ebussieres
Copy link
Member

@huw0 : Just made a PR here (#513). You can take a look to check if it's missing something

@huw0
Copy link
Contributor Author

huw0 commented May 17, 2020

Thanks, yes that looks good.

In order for complete feature parity with servlet, it may be worth also implementing the equivalent access to reactive request, response, session objects from ServerWebExchange.
However this is slightly out of scope for the issue and these are not needed in my particular use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants