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

Merged
merged 2 commits into from
May 27, 2025

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 <ozhurakousky@vmware.com>
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.

@spencergibb spencergibb added this to the 4.3.0 milestone May 27, 2025
@spencergibb spencergibb moved this to In Progress in 2025.0.0 May 27, 2025
Signed-off-by: Spencer Gibb <sgibb@pivotal.io>
@spencergibb spencergibb merged commit 86b4529 into spring-cloud:main May 27, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in 2025.0.0 May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants