/spring-cloud-serverless

Spring Cloud Serverless Native App

Primary LanguageStarlarkMIT No AttributionMIT-0

spring-cloud-serverless repo

This repo provides a simple serverless Hello web app based on Spring Boot and Spring Cloud Function.

It can be deployed as a standalone web app, as a Tanzu Application Platform workload resource or, as a Kubernetes Deployment and Service.

The code

NOTE: The project is configured for Java 11, if you prefer a different version, then modify the java.version property in pom.xml.

The project contains the following Function bean definition:

	@Bean
	public Function<String, String> hello() {
		return (in) -> {
			return "Hello " + in;
		};
	}

This simple serverless app returns the input value, prefixed with "Hello ". This is just a simple example what a Spring Cloud Function app can do. It is defined in src/main/java/com/example/helloapp/HelloAppApplication.java

Deployment

This app can be deployed as a stand-alone web app, as a Tanzu Application Platform (TAP) workload resource or, as a Kubernetes Deployment and Service.

Standalone app with embedded Tomcat server

You can build the project using Maven:

mvn clean package

To run the app using the embedded Tomcat server you can run this command:

mvn spring-boot:run

You can access the app using curl:

curl -w'\n' -H 'Content-Type: text/plain' localhost:8080 -d "Fun"