Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

olegz
Copy link
Contributor

@olegz olegz commented Apr 15, 2025

This one specifically refers to using Spring Cloud Function framework

This one specifically refers to using Spring Cloud Function framework

Signed-off-by: Oleg Zhurakousky <[email protected]>
Copy link
Contributor

@ryanjbaxter ryanjbaxter left a 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.
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants