codecamp

Spring Cloud独立的Web应用程序

spring-cloud-function-web模块具有自动配置,当其包含在Spring Boot web应用程序中(具有MVC支持)时,将激活该配置。还有一个spring-cloud-starter-function-web来收集所有可选的依赖项,以防您只需要简单的入门经验。

激活web配置后,您的应用程序将具有一个MVC端点(默认情况下在“ /”上,但可以使用spring.cloud.function.web.path进行配置),该端点可用于访问应用程序上下文中的功能。支持的内容类型是纯文本和JSON。

方法 路径 请求 响应 状态

GET

/{supplier}

-

Items from the named supplier

200 OK

POST

/{consumer}

JSON object or text

Mirrors input and pushes request body into consumer

202 Accepted

POST

/{consumer}

JSON array or text with new lines

Mirrors input and pushes body into consumer one by one

202 Accepted

POST

/{function}

JSON object or text

The result of applying the named function

200 OK

POST

/{function}

JSON array or text with new lines

The result of applying the named function

200 OK

GET

/{function}/{item}

-

Convert the item into an object and return the result of applying the function

200 OK

如上表所示,端点的行为取决于方法以及传入请求数据的类型。当传入的数据是单值的并且目标函数被声明为显然是单值的(即不返回集合或Flux)时,响应也将包含一个单值。对于多值响应,客户端可以通过发送“接受:文本/事件流”来请求服务器发送的事件流。

如果目录中只有一个功能(消费者等),则路径中的名称是可选的。可以使用管道或逗号分隔功能名称来解决复合函数(管道在URL路径中是合法的,但在命令行上键入会有点尴尬)。

如果目录中只有一个功能,而您又想将一个特定功能映射到根路径(例如“ /”),或者想要组合多个功能然后映射到根路径,则可以这样做通过提供spring.cloud.function.definition属性,该属性实际上由spring- = cloud-function- web模块使用,以为存在某种类型的冲突(例如,多个功能可用等)的情况提供默认映射。

例如,

--spring.cloud.function.definition=foo|bar

上面的属性将组成'foo'和'bar'函数,并将组成的函数映射到“ /”路径。

Message<?>中用输入和输出声明的函数和使用者将在输入消息上看到请求标头,并且输出消息标头将转换为HTTP标头。

在发布文本时,Spring Boot 2.0和更早版本的响应格式可能会有所不同,具体取决于内容协商(提供内容类型和acpt标头以获得最佳效果)。

Spring Cloud Kotlin Lambda支持
Spring Cloud 独立流应用程序
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

三、Spring Cloud Netflix

SpringCloud Hystrix超时和Ribbon客户

SpringCloud 重试失败的请求

五、Spring Cloud Stream

六、SpringCloud Binder实现

SpringCloud 重试RabbitMQ Binder

SpringCloud Dead-Letter队列处理

八、Spring Cloud Sleuth

SpringCloud 当前Span

十二、Spring Cloud for Cloud Foundry

十三、Spring Cloud Contract

Spring Cloud Contract验证程序设置

SrpingCloud Gradle项目

十五、Spring Cloud网关

Spring Cloud 配置路由谓词工厂和网关过滤工厂

Spring Cloud TLS / SSL

Spring Cloud网关配置

SpringCloud 故障排除

十八、Spring Cloud GCP

Spring Cloud GCP Spring资源

Spring Cloud Spring JDBC

Spring Cloud Redis的Cloud Memorystore

Spring Cloud 云身份识别代理(IAP)身份验证

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }