Replies: 1 comment 2 replies
-
inject it in the constructor of the controller |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Say you have something like
The idea is to have this injected in a REST controller method. This way it can benefit from Micronaut's automatic binding of Locale from the HTTP Accept-Language header. But will this work?
My hope is that in this way MyRequestScopedBean will be instantiated on every http request, AND also will have its Locale dependency injected.
Regarding the testing. A test such as this one:
won't work, because Micronaut complains (rightfully) that there is no request available.
So, how can I inject the bean in the test class and in the controller?
Beta Was this translation helpful? Give feedback.
All reactions