GH-718 Improve support for Function bean definition
Added sample for functional bean definition
This commit is contained in:
@@ -37,10 +37,10 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-function-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.springframework.boot</groupId> -->
|
||||
<!-- <artifactId>spring-boot-starter-web</artifactId> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
|
||||
@@ -2,22 +2,19 @@ package example;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent;
|
||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPResponse;
|
||||
|
||||
@SpringBootApplication
|
||||
public class FunctionConfiguration {
|
||||
|
||||
/*
|
||||
* You need this main method or explicit <start-class>example.FunctionConfiguration</start-class>
|
||||
* 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) {
|
||||
SpringApplication.run(FunctionConfiguration.class, args);
|
||||
// empty unless using Custom runtime at which point it should include
|
||||
// SpringApplication.run(FunctionConfiguration.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -31,14 +28,4 @@ public class FunctionConfiguration {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<APIGatewayV2HTTPEvent, APIGatewayV2HTTPResponse> uppercaseApiGateway() {
|
||||
return value -> {
|
||||
APIGatewayV2HTTPResponse response = new APIGatewayV2HTTPResponse();
|
||||
response.setStatusCode(404);
|
||||
response.setBody("Resource not found");
|
||||
return response;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user