-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add documentation for routing to functions #3767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This one specifically refers to using Spring Cloud Function framework Signed-off-by: Oleg Zhurakousky <[email protected]>
ea51cb1
to
81f2444
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions
|
||
=== Spring Cloud Function Handler Function | ||
This feature provides support for transparently routing to Java functions when using https://spring.io/projects/spring-cloud-function[Spring Cloud Function] framework. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "framework"
=== Spring Cloud Function Handler Function | ||
This feature provides support for transparently routing to Java functions when using https://spring.io/projects/spring-cloud-function[Spring Cloud Function] framework. | ||
Gateway routing configuration will be provided as soon as you provide Spring Cloud Function dependency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By placing Spring Cloud Function is on the classpath, Spring Cloud Gateway will automatically configure routes to invoke functions you define as beans. The bean names of the functions will be used as the path of the routes.
For example, given the following configuration:
} | ||
---- | ||
You can now invoke `concat` or `uppercase` as GET or POST request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can invoke the concat
or uppercase
functions by issuing a GET
or POST
request to /concat
or /uppercase
.
Making a GET
request to ``http://localhost:8080/uppercase/hello` will invoke the uppercase
function with the String `hello` and return `HELLO` in the `GET` response body.
Instead of passing the function parameter as a path parameter you can use a POST
request. For example the following cURL command can issued to invoke the concat
function:
[source,bash]
$ curl -d ‘"hello"' -H "Content-Type: application/json" -X POST http://localhost:8080/concat
The response body will contain hellohello
.
Spring Cloud Gateway also supports function composition by issuing a request to a path composed of function names separated by a comma. For example:
[source,bash]
$ curl -d ‘"hello"' -H "Content-Type: application/json" -X POST http://localhost:8080/concat,uppercase
The response body will contain HELLOHELLO
.
This one specifically refers to using Spring Cloud Function framework