KEMBAR78
Add documentation for routing to functions by olegz · Pull Request #3767 · spring-cloud/spring-cloud-gateway · GitHub
Skip to content

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

WARNING: As of version 4.1.7, `HandlerFunctions.http(String)` and `HandlerFunctions.http(URI)` are now deprecated. Please use `HandlerFunctions.http()` in combination with the `BeforeFilterFunctions.uri()` filter instead. This fixes inconsistencies in dealing with the route url request attribute.

=== 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

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants