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

Add proxy support for the rest controller #1100

Closed
Afanas10101111 opened this issue Feb 21, 2024 · 10 comments
Closed

Add proxy support for the rest controller #1100

Afanas10101111 opened this issue Feb 21, 2024 · 10 comments

Comments

@Afanas10101111
Copy link
Contributor

Afanas10101111 commented Feb 21, 2024

Reason/Context

Sometimes it may be useful to forward Microcks' client to real endpoint, so we can implement some logic when we need mock and when a real call. With such feature we don't have to change the url on the client's side if we want both (mock or real) behaviors.

Description

To do this, we can add Spring proxy support and use some header to say that we want proxy behavior

      responses:
        "200":
          headers:
            x-microcks-proxy-to:
              schema:
                type: string
              examples:
                proxy:
                  value: 'http://realhost:8080/some-service/v1/real-pastry'

Implementation ideas

Idea

@lbroudoux
Copy link
Member

Hello. We had some discussions in the past about this feature, but we weren't sure how it fit our target use cases... You give some details above but I'd like to learn more ;-)
Also, on the implementation side, we were thinking about something lighter than this. We try to avoid new dependency when possible ... I'll have a look at this.

@lbroudoux
Copy link
Member

Also, couldn't we integrate this into the existing mechanisms of dispatcher + dispatcher rules?
The dispatcher would be PROXY, and the dispatching rules will be simply the backend URL for the operation?
That would mean that the decision to handle mocks or to proxy would be at the operation level.
WDYT?

@Afanas10101111
Copy link
Contributor Author

This is an interesting idea!
It looks like even more clear way to do proxy. It'll take time to dive into dispatching mechanism, but I'll try this approach.

@lbroudoux
Copy link
Member

For the implementation, I found this article a while ago (https://blogs.ashrithgn.com/writing-a-reverse-proxy-service-in-spring-boot/) and I was thinking if it couldn't be a good starting point ... It seems easy, lightweight and would avoid pulling out new dependencies. What do you think?

@Afanas10101111
Copy link
Contributor Author

I've tried this approach and it works just fine. I'll test it a bit more next week. But it's still demo :) Integration into the dispatching mechanism looks more interesting.

@lbroudoux
Copy link
Member

Looks promising! I wonder if we could expand this to their protocol than rest? At least Soap and maybe GraphQL...
Got another question: are you using Microcks at your company? Is that an enhancement suggestion coming from your real-lige experience? We're always curious to learn more about our adopters ;-)

@Afanas10101111
Copy link
Contributor Author

I wonder if we could expand this to their protocol than rest? At least Soap and maybe GraphQL...

I think it's worth at least trying :) If we can make an elegant implementation with the dispatching mechanism, I hope that expanding to other protocols will be a matter of technique.

Got another question: are you using Microcks at your company? Is that an enhancement suggestion coming from your real-lige experience?

Yes and yes :) Features of Microcks look very interesting, and now I'm working on integrating it into the development process. So all my issues are inspired by integration or users problems.

@lbroudoux
Copy link
Member

Have you ever considered taking the time to chat with us and joining our adopters list?? 😉

@Afanas10101111
Copy link
Contributor Author

I think it's possible, but there are also several stop factors for acting on behalf of a company at this stage. If you have some kind of communication channel for such discussions, we can disscuss this in more detail.

@lbroudoux
Copy link
Member

Please reach out to me via email at: laurent at microcks dot io, or via DM on LinkedIn. We can setup a Zoom call to discuss these points - I'll be on vacations this evening 1 week so expect some news starting March 4th.
Thanks!

@lbroudoux lbroudoux added this to the 1.9.1 milestone Mar 24, 2024
lbroudoux added a commit that referenced this issue Apr 9, 2024
Signed-off-by: Laurent Broudoux <laurent.broudoux@gmail.com>
@lbroudoux lbroudoux self-assigned this Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants