URLDispatcher

URLDispatcher[{patt1content1,patt2content2,}]

represents a dispatcher for deployed URLs that specifies that URLs with relative paths matching the string patterns patti should give content represented by contenti.

Details

  • CloudDeploy[URLDispatcher[]] yields a cloud object corresponding to an active URL dispatcher. All URLs relative to the URL of this cloud object are normally interpreted using the URL dispatcher.
  • Specific deployment of a cloud object to a particular URL, e.g. by CloudDeploy, overrides any rule for that URL given by a URL dispatcher.
  • In the URLs specified by URLDispatcher, the patti are treated as textually appended to the base URL defined by the URL of the deployed URL dispatcher.
  • In CloudDeploy[URLDispatcher[{patt1:>,}]], the patti must start with /.
  • Trailing characters in URLs are by default ignored when the URLs are matched. To force an exact match to the end of a URL, include EndOfString in the string pattern.
  • The contenti must be content suitable for deployment using CloudDeploy.
  • The contenti can contain URLDispatcher.
  • When there are nested URLDispatcher specifications, each successive specification is given whatever trailing part of the URL remains after matching preceding specifications.

Examples

open allclose all

Basic Examples  (2)

URLDispatcher can be used with simple strings:

In[1]:=
Click for copyable input
Out[1]=

Visiting https://www.wolframcloud.com/objects/user-b0c28e9f-876d-4478-9d8b-9e7d18a9ea81/application/form yields a FormFunction:

Visiting https://www.wolframcloud.com/objects/user-b0c28e9f-876d-4478-9d8b-9e7d18a9ea81/application/api yields an APIFunction:

Visiting the bare URL of the CloudObject yields a page not found error:

URLDispatcher also supports generic string patterns:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Generalizations & Extensions  (1)

Possible Issues  (3)

See Also

ExternalBundle  APIFunction  FormFunction  CloudDeploy  HTTPRequestData  GenerateHTTPResponse

Introduced in 2016
(10.4)