Allowing a Slash Character In Spring WebFlux Get Requests - spring

I have a spring WebFlux project and it turns out that I need to allow for a Slash in query parameters for a couple API calls.
In Spring MVC you would use the HttpServletRequest to handle that use case like in this example:
#PathVariable in SpringBoot with slashes in URL
How would you do that with WebFlux? I can't find any good articles about that online.

Related

calling a rest endpoint in a springboot application

which is better alternative for calling REST endpoint in springboot application, calling REST endpoints using WebClient or calling REST endpoints using RestTemplate ?
Spring’s documentation recommends using WebClient, but that’s only a valid recommendation for reactive apps. If you aren’t writing a reactive app, use OpenFeign instead. Like anything else in software, it fits well for some cases, but might complicate things for others. Choosing WebClient to implement the REST endpoint calls is strongly coupled to making your app reactive
RestTemplate gives many advantages if you are using it from within Springboot application, i.e. in your server side to another part of your own app - sort of like an internal call. Because the RestTemplate "knows" all your entities and beans and so if you need to send over or receive an object which is known within your springboot application RestTemplate can map them automatically which is a very nice advantage. If you sending a request to some third party api and do not pass or receive your known entities RestTemplate is still a valid option but it just becomes just another Http client. Its just simply there as part of Springboot provided tools. But in this case you may use any other client as well.

Spring Rest Controller vs Camel rest servlet in micro services --- What's the difference , is camel have any other adv?

In my previous application, i have exposed rest api using spring rest controllers.
Now i'm going to work in spring boot microservice where they have used , camel rest services.
Is there any adv of camel rest compared with spring rest?
Apache Camel offers a REST styled DSL which can be used with Java or
XML. The intention is to allow end users to define REST services using
a REST style with verbs such as get, post, delete etc.
Source https://camel.apache.org/manual/latest/rest-dsl.html
The idea of Camel REST endpoints is to start e Camel Route with a REST Call.
If you don't need Camel Routes it doesn't make sense to use Camel REST.
On the other side Spring MVC provides the ability to define REST APIs that will use other Spring Components to fullfil use case.

Keep Spaces Intact In Http Springboot URL

I am trying to fetch some string consisting spaces in it from Solr from Spring Boot but the spring boot is replacing space with + in the internal HTTP request as in the example below /Tag-+1/ instead of /Tag- 1/.
ex:
q=tags:/Tag-+1/
While if I execute same query q=tags:/Tag- 1/ in solr admin UI(Web Client) it is working. the datatype used is "string". I want to know if spaces can be kept intact in the Spring Boot HTTP request or is there any other solution.

how to make spring mvc functions available for rest calls

I have a spring mvc application which runs correctly,now another colleague wants to call the same functions from another application but he needs REST URL of my functions.
how is it possible to provide the same functionality through spring REST?
is it just with new annotations .please provide some resource to show me how to do it.
when server has a service, only legal clients which had any contracts with server can access it. And clients can use service by the way such as: use RestTemplate to get/post request to URL of service, and clients can get data as JSON, or XML type if you have an equivalent object as this image:
Also, a service can be support as a interface, ex: google search is a service supported by google, but it's not rest service.
If you know each other URL address you can consume each other REST API from java code by using RestTemplate object.
I would advise you to go over the Spring starter guide which deals with that issue, here is the link (Consuming a RESTful Web Service):
https://spring.io/guides/gs/consuming-rest/

Forward Spring HTTP Request

I have a restful web service written using Spring WebMVC that will mostly be used to orchestrate other services. In some cases these services are on the same server, in some cases they are not. I have a few requests (GET and POST) that will be direct pass throughs to another service. Is there a way to blindly forward all GET and POST data from a request for certain URLs without knowing anything about the data in the request?
Ideally, I would like to be able to say all requests for http://server1/myService/user/... should forward to http://server2/user/... with all of the GET and POST parameters forwarded with it.
For the services on the same server, if they're being served by the same Spring MVC application, you could use RedirectViews and/or the "redirect:" prefix.
For those on another server, the best thing I can think of would be to use a servlet filter, similar to the approach suggested by this post: spring mvc redirect path and all children to another domain

Resources