Class SubdomainExtensionBasedMapper

Extends the functionality of an ExtensionBasedMapper to support identifiers containing subdomains. This is mostly only relevant in case you want to support multiple pods with subdomain identifiers in a single ResourceStore.

When converting to/from file paths, the subdomain is interpreted as a folder in the rootFilePath. The rest of the path is then interpreted relative to that folder. E.g. http://alice.test.com/foo results in the relative path /alice/foo.

In case there is no subdomain in the URL, the baseSubdomain parameter is used instead. E.g., if the baseSubdomain is "www", http://test.com/foo would result in the relative path /www/foo. This means that there is no identifier that maps to the rootFilePath itself. To prevent the possibility of 2 identifiers linking to the same file, identifiers containing the default subdomain are rejected. E.g., http://www.test.com/foo would result in a 403, even if http://test.com/foo exists.

Hierarchy

Constructors

Properties

baseParts: {
    rest: string;
    scheme: string;
}

Type declaration

  • rest: string
  • scheme: string
baseRequestURI: string
baseSubdomain: string
logger: Logger = ...
regex: RegExp
rootFilepath: string
unknownMediaTypeExtension: "unknown" = 'unknown'

Methods

  • Maps the given document identifier to a file path, possibly making alterations to the direct translation (for instance, based on its content type)). Determines the content type if none was provided.

    Parameters

    • identifier: ResourceIdentifier

      The input identifier.

    • filePath: string

      The direct translation of the identifier onto the file path.

    • Optional contentType: string

      The content-type provided with the request.

    Returns Promise<ResourceLink>

    A ResourceLink with all the necessary metadata.