You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/spring-cloud-gateway-server-webmvc/java-routes-api.adoc
+23-7Lines changed: 23 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -59,8 +59,9 @@ The most basic handler function is `http()` `HandlerFunction`. If a `URI` is sup
59
59
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.
60
60
61
61
=== 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:
64
65
65
66
[source,xml]
66
67
----
@@ -95,9 +96,24 @@ public class DemoFunctionGatewayApplication {
95
96
}
96
97
}
97
98
----
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
+
----
101
118
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`
0 commit comments