I have a basic Spring Cloud Function application with two declared functions "lowercase" and "uppercase". If I create the application as a normal @SpringBootApplication and annotate both functions as @Beans (functional beans), everything works just fine. Both functions are exposed via seperate HTTP endpoints and I'm able to call the functions via:
- curl localhost:8080/uppercase -H "Content-Type: text/plain" -d 'My input text'
- curl localhost:8080/lowercase -H "Content-Type: text/plain" -d 'My input text'
Now I converted the application's main class to "functional form" to improve application startup time (as adviced in the official doc: http://cloud.spring.io/spring-cloud-function/multi/multi__functional_bean_definitions.html):
@SpringBootConfiguration
public class LambdaMicroserviceApplication implements ApplicationContextInitializer<GenericApplicationContext> {
public Function<String, String> uppercase() {
return String::toUpperCase;
}
public Function<String, String> lowercase() {
return String::toLowerCase;
}
public static void main(String[] args) {
FunctionalSpringApplication.run(LambdaMicroserviceApplication.class, args);
}
@Override
public void initialize(GenericApplicationContext context) {
context.registerBean("uppercase", FunctionRegistration.class,
() -> new FunctionRegistration<>(uppercase())
.type(FunctionType.from(String.class).to(String.class)));
context.registerBean("lowercase", FunctionRegistration.class,
() -> new FunctionRegistration<>(lowercase())
.type(FunctionType.from(String.class).to(String.class)));
}
}
Problem:
Only one single endpoint now gets exposed directly at the root path:
curl localhost:8080/ -H "Content-Type: text/plain" -d 'My input text'
It calls the "uppercase" function internally, regardless of registration order of the beans in the initialize function.
Question:
Is there a way to call both functions again via their dedicated endpoints: localhost:8080/uppercase and localhost:8080/lowercase?