What is the difference between Router and Annotated Controllers?
Clash Royale CLAN TAG#URR8PPP
What is the difference between Router and Annotated Controllers?
I'm using WebFlux for Web development.
And I find 2 ways to express request mappings.
@Controller
@RestController
RouterFunction
RouterFunction
HandlerFunction
I find the second harder to use than the first and also I do not know the difference between them.
So I wanted to ask which performs better 2 or 1 ?
Thanks my friends!
Yes,right.I'm just giving an example.
– MrXionGe
Aug 11 at 14:58
2 Answers
2
Let me start with your last question
Is 2 better than 1, in performance?
No, there is no difference in the performance.
I find that 2 is harder to use than 1
That is absolutely based on individual preference. May be you are used to imperative style of programming. And hence you feel it easy to write(Trust me after a while you would feel the same with Router Functions as well)
Basically Router Functions are one step towards functional style of programming. Spring wanted to users to have the flexibility to configure routes in functional style.
Apart from this there is no difference between Controllers and Router Functions.
Well. Thank you very much! I understand part of it.
– MrXionGe
Aug 11 at 14:58
@MrXionGe which part did you not understand
– pvpkiran
Aug 13 at 7:29
First, thanks for your concern. About Mono and Flux.What's the difference between using Mono or Flux and not using it? I don't think they have much difference in performance.Because I make a test by JMeter
– MrXionGe
Aug 14 at 8:04
If we leave individual preference, there is one explicit difference in filters.
The WebFlux framework provides two types of filters: WebFilters and HandlerFilterFunctions.
The main difference between them is that WebFilter implementations work for all endpoints and HandlerFilterFunction implementations will only work for Router-based ones.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
'@RestControlle' = '@Controller' + '@ResponseBody' by default on methods
– Errabi Ayoub
Aug 10 at 14:24