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:
/
prefix)/
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))
An array of rules.
Must contain a minimum of 1
items
A single rule for matching URL along with the resulting settings object.
No Additional PropertiesUse this field to describe the rule and its reason for being here.
Must be at least 1
characters long
Defines how we match the URL.
No Additional PropertiesAlways match regardless. This is useful for defining a default rule. The value for this should always be true
.
Matches based on URL. URLs are normalized using our implementation of the URI Normalization rules.
No Additional PropertiesExact string matching using Python ==
.
Must be at least 1
characters long
Regex string matching based on Python style regexes using re.search.
Must be at least 1
characters long
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.
Exact string matching using Python ==
.
Must be at least 1
characters long
Regex string matching based on Python style regexes using re.search.
Must be at least 1
characters long
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.
Exact string matching using Python ==
.
Must be at least 1
characters long
Regex string matching based on Python style regexes using re.search.
Must be at least 1
characters long
An object relevant to this rule.
No Additional PropertiesHippocrates settings.
No Additional PropertiesRegion where Hippocrates is hosted.
The fully qualified GQL endpoint to use.
Care settings.
No Additional PropertiesJavascript-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 path
s will be denoted by just /
.
Must be at least 1
characters long
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 settings.
No Additional PropertiesThe URL to the login application.
Rules that are not enabled
will be ignored. Defaults to true
.