32 lines
858 B
Java
32 lines
858 B
Java
package example;
|
|
|
|
import java.util.function.Function;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
@SpringBootApplication
|
|
public class FunctionConfiguration {
|
|
|
|
/*
|
|
* You need this main method (empty) or explicit <start-class>example.FunctionConfiguration</start-class>
|
|
* in the POM to ensure boot plug-in makes the correct entry
|
|
*/
|
|
public static void main(String[] args) {
|
|
// empty unless using Custom runtime at which point it should include
|
|
// SpringApplication.run(FunctionConfiguration.class, args);
|
|
}
|
|
|
|
@Bean
|
|
public Function<String, String> uppercase() {
|
|
return value -> {
|
|
if (value.equals("exception")) {
|
|
throw new RuntimeException("Intentional exception which should result in HTTP 417");
|
|
}
|
|
else {
|
|
return value.toUpperCase();
|
|
}
|
|
};
|
|
}
|
|
}
|