Skip to content

Commit 0465569

Browse files
authored
Update java-routes-api.adoc
Signed-off-by: Spencer Gibb <sgibb@pivotal.io>
1 parent 81f2444 commit 0465569

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

docs/modules/ROOT/pages/spring-cloud-gateway-server-webmvc/java-routes-api.adoc

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ The most basic handler function is `http()` `HandlerFunction`. If a `URI` is sup
5959
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.
6060

6161
=== Spring Cloud Function Handler Function
62-
This feature provides support for transparently routing to Java functions when using https://spring.io/projects/spring-cloud-function[Spring Cloud Function] framework.
63-
Gateway routing configuration will be provided as soon as you provide Spring Cloud Function dependency.
62+
By placing https://spring.io/projects/spring-cloud-function[Spring Cloud Function] 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.
63+
64+
For example, given the following configuration:
6465

6566
[source,xml]
6667
----
@@ -95,9 +96,24 @@ public class DemoFunctionGatewayApplication {
9596
}
9697
}
9798
----
98-
You can now invoke `concat` or `uppercase` as GET or POST request
99-
For example, for simple GET you can invoke `http://localhost:8080/uppercase/hello` where `/hello` becomes a payload and you will get _HELLO_ in response.
100-
You can also use POST `curl -d ‘"hello"' -H "Content-Type: application/json" -X POST http://localhost:8080/concat`
99+
You can invoke the `concat` or `uppercase` functions by issuing a `GET` or `POST` request to `/concat` or `/uppercase`.
100+
101+
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.
102+
103+
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:
104+
105+
[source,bash]
106+
----
107+
$ curl -d ‘"hello"' -H "Content-Type: application/json" -X POST http://localhost:8080/concat
108+
----
109+
110+
The response body will contain `hellohello`.
111+
112+
Spring Cloud Gateway also supports function composition by issuing a request to a path composed of function names separated by a comma. For example:
113+
114+
[source,bash]
115+
----
116+
$ curl -d ‘"hello"' -H "Content-Type: application/json" -X POST http://localhost:8080/concat,uppercase
117+
----
101118

102-
Additionally you can now benefit from function composition. For example `curl -d ‘"hello"' -H "Content-Type: application/json" -X POST http://localhost:8080/concat,uppercase`
103-
will result in _HELLOHELLO_ response.
119+
The response body will contain `HELLOHELLO`.

0 commit comments

Comments
 (0)