Home Schema Example JSON Schema

Discovery Settings

Type: object

Heimdall discovery is a simple pattern used by frontend to discover basic application settings from a universal endpoint based on simple URL rules.
This is useful for retrieving settings such as GQL endpoints and language options.

Discovery settings are organized as a sequence of URL matching rules.
Each rule defines how a URL is matched and if matched, what the settings are.
There are several ways to match rules:

  1. Exact match of URL
  2. Regex match of URL
  3. Exact match of host
  4. Regex match of host
  5. Exact match of path (with / prefix)
  6. Regex match of path (with / prefix)

Regex are based on Python style regexes using re.search.
URL nomenclatures are based on definitions in RFC 3986: Uniform Resource Identifier (URI): Generic Syntax.
We normalize URI using our implementation loosely based on guidelines described in URI normalization (Wikipedia).
The actual implementation can be found in scalpel.common.uri code and examples of the URI normalization can be found in scalpel.tests.common.uri test cases.
URL, host, and path rules may be used together.

Rule settings are simple objects/dictionaries/maps with an opinionated convention based on segregation by applications.
Example:

hippocrates:
  gql_endpoint: https://example.com/gql

login:
  url: https://login.com/

care:
  language: id

When a URL match multiple rules, the individual rule settings are merged recursively in order of preference from the first matched rule to the last.
That is, rule settings objects are union-ized with earlier rule settings retaining their values.

The pseudo-code for generating the discovery setting is as follows:

url ← normalize_uri('https://subdomain.example.com/a/b/c')

matched_settings ← []
for each rule in rules
  if url matches rule
    matched_settings ← matched_settings + [rule settings]

return deep_merge(reversed(matched_settings))
No Additional Properties

Rules

Type: array of object

An array of rules.

Must contain a minimum of 1 items

No Additional Items

Each item of this array must be:

Rule

Type: object

A single rule for matching URL along with the resulting settings object.

No Additional Properties

Description

Type: string

Use this field to describe the rule and its reason for being here.

Must be at least 1 characters long

Match


Defines how we match the URL.

No Additional Properties

Type: object

The following properties are required:

  • all
Type: object

The following properties are required:

  • url
Type: object

The following properties are required:

  • host
Type: object

The following properties are required:

  • path

All

Type: boolean

Always match regardless. This is useful for defining a default rule. The value for this should always be true.

URL

Type: object

Matches based on URL. URLs are normalized using our implementation of the URI Normalization rules.

No Additional Properties

Type: object

The following properties are required:

  • exact
Type: object

The following properties are required:

  • regex

Exact

Type: string

Exact string matching using Python ==.

Must be at least 1 characters long

Regex

Type: string

Regex string matching based on Python style regexes using re.search.

Must be at least 1 characters long

Host

Type: object

Matches based on host component of the URL. As defined in RFC 3986, host does not include ports. Hosts are normalized using using our implementation of the URI Normalization rules.

No Additional Properties

Type: object

The following properties are required:

  • exact
Type: object

The following properties are required:

  • regex

Exact

Type: string

Exact string matching using Python ==.

Must be at least 1 characters long

Regex

Type: string

Regex string matching based on Python style regexes using re.search.

Must be at least 1 characters long

Path

Type: object

Matches based on the path component of the URL. Paths are normalized using percent encoding based on rule defined in the RFC. Paths are normalized using our implementation of the URI Normalization rules.

No Additional Properties

Type: object

The following properties are required:

  • exact
Type: object

The following properties are required:

  • regex

Exact

Type: string

Exact string matching using Python ==.

Must be at least 1 characters long

Regex

Type: string

Regex string matching based on Python style regexes using re.search.

Must be at least 1 characters long

Settings

Type: object

An object relevant to this rule.

No Additional Properties

Hippocrates

Type: object

Hippocrates settings.

No Additional Properties

Region

Type: enum (of string)

Region where Hippocrates is hosted.

Must be one of:

  • "id"
  • "sg"

GQL Endpoint

Type: stringFormat: uri

The fully qualified GQL endpoint to use.

Care

Type: object

Care settings.

No Additional Properties

Clinic Domain Regex

Type: string

Javascript-based regular expression to extract clinic domain from URL path. There will be a named capturing group domain to denote the domain within the path. Note that for consistency, path will always include a / at the beginning. Empty paths will be denoted by just /.

Must be at least 1 characters long

Language

Type: string

Default language for this URL. This is used prior to any clinic settings. Defaults to en if not set.

Must be at least 1 characters long

Login

Type: object

Login settings.

No Additional Properties

URL

Type: stringFormat: uri

The URL to the login application.

Enabled

Type: boolean

Rules that are not enabled will be ignored. Defaults to true.