Kotlin spring cloud function example with different types of creation function, supplier and consumer. This example also contains Kotlin lambdas configured as Spring beans. There are also examples with flux - reactive type.
git clone git@github.com:wojciech-zurek/kotlin-spring-cloud-function-example.git
cd kotlin-spring-cloud-function-example/
./gradlew bootRun
cd kotlin-spring-cloud-function-example/
./gradlew bootJar
java -jar build/libs/kotlin-spring-cloud-function-example-0.0.1-SNAPSHOT.jar
echo "Hello World" | http POST :8080/upperCase
HTTP/1.1 200 OK
Content-Length: 12
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
HELLO WORLD
echo "Hello World" | http POST :8080/lowerCase
HTTP/1.1 200 OK
Content-Length: 17
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
[
"hello world\n"
]
http POST :8080/user name=admin age=30
HTTP/1.1 200 OK
Content-Length: 34
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
[
{
"age": 30,
"id": 0,
"name": "admin"
}
]
echo "Message to log" | http POST :8080/log
HTTP/1.1 200 OK
content-length: 0
echo "Message to reverse" | http POST :8080/reverse
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
[
"\nesrever ot egasseM"
]
echo "Sample message" | http POST :8080/statistic
HTTP/1.1 200 OK
Content-Length: 56
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
{
"\n": 1,
" ": 1,
"a": 2,
"e": 3,
"g": 1,
"l": 1,
"m": 2,
"p": 1,
"s": 3
}
http :8080/unixTime
HTTP/1.1 200 OK
Content-Length: 10
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
1571218287
http :8080/pi
HTTP/1.1 200 OK
Content-Length: 17
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
3.141592653589793
echo 12 | http :8080/square
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: application/json;charset=UTF-8
accept-encoding: gzip, deflate
connection: keep-alive
user-agent: HTTPie/1.0.3
144
echo "Test" | http :8080/stupid
HTTP/1.1 200 OK
content-length: 0