Responsible for everything related to ETag generation and comparison. ETags are constructed in such a way they can both be used for the standard ETag usage of comparing representations, but also to see if two ETags of different representations correspond to the same resource state.

interface ETagHandler {
    getETag: ((metadata: RepresentationMetadata) => undefined | string);
    matchesETag: ((metadata: RepresentationMetadata, eTag: string, strict: boolean) => boolean);
    sameResourceState: ((eTag1: string, eTag2: string) => boolean);
}

Implemented by

Properties

getETag: ((metadata: RepresentationMetadata) => undefined | string)

Generates an ETag for the given metadata. Returns undefined if no ETag could be generated.

Type declaration

    • (metadata): undefined | string
    • Parameters

      Returns undefined | string

matchesETag: ((metadata: RepresentationMetadata, eTag: string, strict: boolean) => boolean)

Validates whether the given metadata corresponds to the given ETag.

Type declaration

    • (metadata, eTag, strict): boolean
    • Parameters

      • metadata: RepresentationMetadata

        Metadata of the resource.

      • eTag: string

        ETag to compare to.

      • strict: boolean

        True if the comparison needs to be on representation level. False if it is on resource level and the content-type doesn't matter.

      Returns boolean

sameResourceState: ((eTag1: string, eTag2: string) => boolean)

Validates whether 2 ETags correspond to the same state of a resource, independent of the representation the ETags correspond to.

Type declaration

    • (eTag1, eTag2): boolean
    • Parameters

      • eTag1: string

        First ETag to compare.

      • eTag2: string

        Second ETag to compare.

      Returns boolean