TypedRest for TypeScript - v0.4.0
    Preparing search index...

    Class Endpoint

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new endpoint.

      Parameters

      • referrer: Endpoint | undefined

        The endpoint used to navigate to this one. Must be defined except for top-level endpoint.

      • uri: string | URL

        The HTTP URI of the remote element. May be relative if referrer is defined.

      • Optionalserializer: Serializer

        Controls the serialization of entities sent to and received from the server. Taken from referrer instead if it is defined.

      • OptionalerrorHandler: ErrorHandler

        Handles errors in responses. Taken from referrer instead if it is defined.

      • OptionallinkExtractor: LinkExtractor

        Extracts links from responses. Taken from referrer instead if it is defined.

      • OptionalhttpClient: HttpClient

        The HTTP client used to communicate with the remote resource. Taken from referrer instead if it is defined.

      Returns Endpoint

    Properties

    errorHandler: ErrorHandler

    Handles errors in responses.

    httpClient: HttpClient

    The HTTP client used to communicate with the remote resource.

    linkExtractor: LinkExtractor

    Extracts links from responses.

    serializer: Serializer

    Controls the serialization of entities sent to and received from the server.

    uri: URL

    The HTTP URI of the remote resource.

    Methods

    • Resolves all links with a specific relation type. Uses cached data from last response.

      Parameters

      • rel: string

        The relation type of the links to look for.

      Returns { title?: string; uri: URL }[]

    • Retrieves a link template with a specific relation type. Uses cached data from last response. Prefer linkTemplate when possible.

      Parameters

      • rel: string

        The relation type of the link template to look for.

      Returns string

      errors!NotFoundError: No link template with the specified rel could be found.

    • Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors.

      Parameters

      • response: Response

        The response to process.

      Returns Promise<void>

    • Handles allowed HTTP methods and other capabilities reported by the server.

      Parameters

      • response: Response

      Returns void

    • Shows whether the server has indicated that a specific HTTP method is currently allowed. Uses cached data from last response.

      Parameters

      • method: HttpMethod

        The HTTP methods (e.g. GET, POST, ...) to check.

      Returns boolean | undefined

      true if the method is allowed, false if the method is not allowed, undefined if no request has been sent yet or the server did not specify allowed methods.

    • Resolves a relative URI using this endpoint's URI as the base.

      Parameters

      • relativeUri: string

        The relative URI to resolve. Prepend ./ to imply a trailing slash in the base URI even if it is missing there.

      Returns URL

    • Resolves a single link with a specific relation type. Uses cached data from last response.

      Parameters

      • rel: string

        The relation type of the link to look for.

      Returns URL

      errors!NotFoundError: No link with the specified rel could be found.

    • Resolves a link template with a specific relation type. Uses cached data from last response.

      Parameters

      • rel: string

        The relation type of the link template to look for.

      • variables: { [key: string]: any }

        Variables for resolving the template.

      Returns URL

      errors!NotFoundError: No link template with the specified rel could be found.

    • Sends an HTTP request to this endpoint's URI. Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors.

      Parameters

      • method: HttpMethod

        The HTTP method to use.

      • Optionalsignal: AbortSignal

        Used to cancel the request.

      • Optionalheaders: HeadersInit

        The HTTP headers to set.

      • Optionalbody: BodyInit

        The body to send.

      Returns Promise<Response>

    • Registers one or more default links for a specific relation type. These links are used when no links with this relation type are provided by the server. This should only be called during initial setup of the endpoint.

      Parameters

      • rel: string

        The relation type of the link to add.

      • Optionalhref: string

        The href of the link relative to this endpoint's URI. Leave unspecified to remove any previous entries for the relation type.

      Returns void

    • Registers a default link template for a specific relation type. This template is used when no template with this relation type is provided by the server. This should only be called during initial setup of the endpoint.

      Parameters

      • rel: string

        The relation type of the link to add.

      • Optionalhref: string

        The templates href relative to this endpoint's URI. Leave unspecified to remove any previous entries for the relation type.

      Returns void

    • Adds a trailing slash to the URI if it does not already have one.

      Parameters

      • uri: string | URL

      Returns URL