Web application routing

Location path

Path in the assembly catalog

/era_env/priv/metadata/url_routes.json

Overview

Routing for HTTP requests to the web server.

Applies in addition to the system’s web server descriptor, organizing automatic redirects and substitutions when specific pages are accessed.

For example, a reference to /scripteditor is redirected to /scripteditor/. And that in turn substitutes the contents of /scripteditor/index.html without redirection. redirection.

The url_routes.json is expected to contain the redirect and substitution pages of all system web applications included in the distribution.

Format:
[
  {
    "url": str,
    "type": "redirect" | "static" | "static_dir_with_404",
    "to": str,
    "code": int,
    "dir": str
  },
  ...
]
Table 1. Fields
Field Description

"url"

The relative-root URL to be routed. Supports wildcard (*) to specify the remainder of the path.

"type"

routing mode:

  • "redirect" – returns HTTP response 3xx, the specific code is specified in the field "code";

  • "static" – outputs the specific resource located at the URL in the field "to";

  • "static_dir_with_404" – searches for a resource in the specified directory ("dir" field) and outputs it. If it is not available, it gives the resource located at the URL in the "to" field. Used in conjunction with wildcard (*) in the field "url".

"to"

the new URL at which the resource is accessible.

"code"

(for type = redirect) the HTTP response code with which the redirect is made.

"dir"

(for type = static_dir_with_404) the directory in which the arbitrary resource is searched.

Example

Example:
[
  { "url": "/",          "type": "static",   "to": "/index.html" },
  { "url": "/login",     "type": "static",   "to": "/index.html" },

  { "url": "/doc",       "type": "redirect", "to": "/doc/", "code": 301 },
  { "url": "/doc/",      "type": "static",   "to": "/doc/index.html" },

  { "url": "/selector",  "type": "redirect", "to": "/selector/", "code": 301 },
  { "url": "/selector/", "type": "static",   "to": "/selector_dist/index.html" },
  {
    "url": "/selector/*",
    "type": "static_dir_with_404",
    "to": "/selector_dist/index.html",
    "dir": "/selector_dist/"
  },

  { "url": "/scripteditor",  "type": "redirect", "to": "/scripteditor/", "code": 301 },
  { "url": "/scripteditor/", "type": "static",   "to": "/scripteditor/index.html" },

  { "url": "/webphone",      "type": "redirect", "to": "/webphone/", "code": 301 },
  { "url": "/webphone/",     "type": "static",   "to": "/webphone/index.html" }
]