Skip to main content
Version: Next

ServiceRequest

A request consumed by a service.

Index

Constructors

constructor

Methods

ack

  • ack(): Promise<void>
  • Acknowledge the request. Used for SEND requests


    Returns Promise<void>

    a Promise that completes once the ack is sent

body

  • body(): Object
  • Get the request body.


    Returns Object

    the request body

fail

  • fail(error: Error): Promise<void>
  • Reply to the request with and error.


    Parameters

    • error: Error

      the error to send

    Returns Promise<void>

    a Promise that completes once the error is sent

notifyOn

  • notifyOn(topic: string): Promise<string>
  • Send the topic where the requester should listen to get notifications. Used for OBSERVE requests. The string returned by the Promise is the id of that subscription. It can be used in parallel with the Service.setUnsubscriptionHandler method of the service to execute instructions when a subscription is removed.


    Parameters

    • topic: string

      the topic where the client should

    Returns Promise<string>

    a Promise that completes once the consumer has started to the listen to notifications. The

reply

  • reply(payload: Object): Promise<void>
  • Send a reply to the request with a content payload. Used for GET requests


    Parameters

    • payload: Object

      the payload of the reply

    Returns Promise<void>

    a Promise that completes once the reply is sent

requestType

  • Return the type of this Service Request


    Returns ServiceRequestType

    the type of this request.

userTag

  • userTag(): Promise<string>
  • Get the requesting client’s user tag.


    Returns Promise<string>

    the user tag