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

Expose particular REST controller on specific port using Spring Webflux #5

Open
amolai opened this issue Sep 7, 2022 · 0 comments
Open

Comments

@amolai
Copy link

amolai commented Sep 7, 2022

Working on a spring boot based application and using spring webflux, we are exposing 3 ports

  1. server.port

  2. management.server.port (actuator) and are planning to expose another port called as admin port.

We want to expose a specific REST controller on this admin port which will be private. This api will provide all the admin level configuration and will not be available publicly to the user.

Note: We don't want to expose api on actuator port. Need to open a new port.

Using the following code to open a new port by starting a new server instance.

`@Configuration
public class NettyServerForAdminPort {

@Value("${admin.port}")
private Integer adminPort;

@Autowired
HttpHandler httpHandler;

WebServer http;

@PostConstruct
public void start() {
  ReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(8081);
  this.http = factory.getWebServer(this.httpHandler);
  this.http.start();
}

@PreDestroy
public void stop() {
  this.http.stop();
}

}`

Spring boot, webflux doesn't provide an out of box solution for this, can this be achieved using RouterFunction ??
Any insights here would be helpful.

Thank you

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

No branches or pull requests

1 participant