Files
spring-cloud-static/Greenwich.SR3/multi/multi__standalone_web_applications.html
2019-09-11 20:32:25 -04:00

16 lines
8.9 KiB
HTML

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>127.&nbsp;Standalone Web Applications</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function_2.html" title="Part&nbsp;XVI.&nbsp;Spring Cloud Function"><link rel="prev" href="multi__function_catalog_and_flexible_function_signatures.html" title="126.&nbsp;Function Catalog and Flexible Function Signatures"><link rel="next" href="multi__standalone_streaming_applications.html" title="128.&nbsp;Standalone Streaming Applications"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">127.&nbsp;Standalone Web Applications</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__function_catalog_and_flexible_function_signatures.html">Prev</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;XVI.&nbsp;Spring Cloud Function</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__standalone_streaming_applications.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_standalone_web_applications" href="#_standalone_web_applications"></a>127.&nbsp;Standalone Web Applications</h2></div></div></div><p>The <code class="literal">spring-cloud-function-web</code> module has autoconfiguration that
activates when it is included in a Spring Boot web application (with
MVC support). There is also a <code class="literal">spring-cloud-starter-function-web</code> to
collect all the optional dependencies in case you just want a simple
getting started experience.</p><p>With the web configurations activated your app will have an MVC
endpoint (on "/" by default, but configurable with
<code class="literal">spring.cloud.function.web.path</code>) that can be used to access the
functions in the application context. The supported content types are
plain text and JSON.</p><div class="informaltable"><table class="informaltable" style="border-collapse: collapse;border-top: 1px solid ; border-bottom: 1px solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"><col class="col_4"><col class="col_5"></colgroup><thead><tr><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Method</th><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Path</th><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Request</th><th style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top">Response</th><th style="border-bottom: 1px solid ; " align="left" valign="top">Status</th></tr></thead><tbody><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>GET</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>/{supplier}</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>-</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>Items from the named supplier</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>200 OK</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>POST</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>/{consumer}</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>JSON object or text</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>Mirrors input and pushes request body into consumer</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>202 Accepted</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>POST</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>/{consumer}</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>JSON array or text with new lines</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>Mirrors input and pushes body into consumer one by one</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>202 Accepted</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>POST</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>/{function}</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>JSON object or text</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>The result of applying the named function</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>200 OK</p></td></tr><tr><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>POST</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>/{function}</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>JSON array or text with new lines</p></td><td style="border-right: 1px solid ; border-bottom: 1px solid ; " align="left" valign="top"><p>The result of applying the named function</p></td><td style="border-bottom: 1px solid ; " align="left" valign="top"><p>200 OK</p></td></tr><tr><td style="border-right: 1px solid ; " align="left" valign="top"><p>GET</p></td><td style="border-right: 1px solid ; " align="left" valign="top"><p>/{function}/{item}</p></td><td style="border-right: 1px solid ; " align="left" valign="top"><p>-</p></td><td style="border-right: 1px solid ; " align="left" valign="top"><p>Convert the item into an object and return the result of applying the function</p></td><td style="" align="left" valign="top"><p>200 OK</p></td></tr></tbody></table></div><p>As the table above shows the behaviour of the endpoint depends on the method and also the type of incoming request data. When the incoming data is single valued, and the target function is declared as obviously single valued (i.e. not returning a collection or <code class="literal">Flux</code>), then the response will also contain a single value.
For multi-valued responses the client can ask for a server-sent event stream by sending `Accept: text/event-stream".</p><p>If there is only a single function (consumer etc.) in the catalog, the name in the path is optional.
Composite functions can be addressed using pipes or commas to separate function names (pipes are legal in URL paths, but a bit awkward to type on the command line).</p><p>For cases where there is more then a single function in catalog and you want to map a specific function to the root
path (e.g., "/"), or you want to compose several functions and then map to the root path you can do so by providing
<code class="literal">spring.cloud.function.definition</code> property which essentially used by spring-=cloud-function-web module to provide
default mapping for cases where there is some type of a conflict (e.g., more then one function available etc).</p><p>For example,</p><pre class="screen">--spring.cloud.function.definition=foo|bar</pre><p>The above property will compose 'foo' and 'bar' function and map the composed function to the "/" path.</p><p>Functions and consumers that are declared with input and output in <code class="literal">Message&lt;?&gt;</code> will see the request headers on the input messages, and the output message headers will be converted to HTTP headers.</p><p>When POSTing text the response format might be different with Spring Boot 2.0 and older versions, depending on the content negotiation (provide content type and accpt headers for the best results).</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__function_catalog_and_flexible_function_signatures.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function_2.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__standalone_streaming_applications.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">126.&nbsp;Function Catalog and Flexible Function Signatures&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;128.&nbsp;Standalone Streaming Applications</td></tr></table></div></body></html>