This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Object - websub : Notification

Represents the WebSub Content Delivery Request received.

Methods

Retrieves the query parameters of the content delivery request as a map.

Retrieves the mime:Entity associated with the content delivery request.

Returns whether the requested header key exists in the header map of the content delivery request.

Returns the value of the specified header.

Retrieves all the header values to which the specified header key maps to.

Retrieves all the names of the headers present in the content delivery request.

Retrieves the type of the payload of the content delivery request (i.

Extracts json payload from the content delivery request.

Extracts xml payload from the content delivery request.

Extracts text payload from the content delivery request.

Retrieves the request payload as a ByteChannel except in the case of multiparts.

Retrieves the request payload as a byte[].

Retrieves the form parameters from the content delivery request as a map.

getQueryParams

()

returns map<string[]>

Retrieves the query parameters of the content delivery request as a map.

 map<string[]> payload = notification.getTextPayload();
  • Return Type

    (map<string[]>)
  • String-constrained array map of the query params

getEntity

()

returns Entity | error

Retrieves the mime:Entity associated with the content delivery request.

 mime:Entity|error payload = notification.getEntity();
  • Return Type

    (Entity | error)
  • The mime:Entity of the request or else an error if entity construction fails

hasHeader

(string headerName)

returns boolean

Returns whether the requested header key exists in the header map of the content delivery request.

 boolean payload = notification.hasHeader("name");

Parameters

  • headerName string
  • The header name

  • Return Type

    (boolean)
  • true if the specified header key exists or else false

getHeader

(string headerName)

returns string

Returns the value of the specified header. If the specified header key maps to multiple values, the first of these values is returned.

 string payload = notification.getHeader("name");

Parameters

  • headerName string
  • The header name

  • Return Type

    (string)
  • The first header value for the specified header name or else panic if no header is found. Ideally, the Notification.hasHeader() needs to be used to check the existence of a header initially.

getHeaders

(string headerName)

returns string[]

Retrieves all the header values to which the specified header key maps to.

 string[] headersNames = notification.getHeaders("name");

Parameters

  • headerName string
  • The header name

  • Return Type

    (string[])
  • The header values the specified header key maps to or else panic if no header is found. Ideally, the Notification.hasHeader() needs to be used to check the existence of a header initially.

getHeaderNames

()

returns string[]

Retrieves all the names of the headers present in the content delivery request.

 string[] headersNames = notification.getHeaderNames();
  • Return Type

    (string[])
  • An array of all the header names

getContentType

()

returns string

Retrieves the type of the payload of the content delivery request (i.e: the content-type header value).

 string contentType = notification.getContentType();
  • Return Type

    (string)
  • The content-type header value as a string

getJsonPayload

()

returns json | error

Extracts json payload from the content delivery request.

 json|error payload = notification.getJsonPayload();
  • Return Type

    (json | error)
  • The json payload or else an error in case of errors. If the content; type is not JSON, an error is returned.

getXmlPayload

()

returns xml | error

Extracts xml payload from the content delivery request.

 xml|error result = notification.getXmlPayload();
  • Return Type

    (xml | error)
  • The xml payload or else an error in case of errors. If the content; type is not XML, an error is returned.

getTextPayload

()

returns string | error

Extracts text payload from the content delivery request.

 string|error result = notification.getTextPayload();
  • Return Type

    (string | error)
  • The payload as a text or else an error in case of errors. If the content type is not of type text, an error is returned.

getByteChannel

()

returns ReadableByteChannel | error

Retrieves the request payload as a ByteChannel except in the case of multiparts.

 io:ReadableByteChannel|error result = notification.getByteChannel();
  • Return Type

    (ReadableByteChannel | error)
  • A byte channel from which the message payload can be read or esle an error in case of errors

getBinaryPayload

()

returns byte[] | error

Retrieves the request payload as a byte[].

 byte[]|error payload = notification.getBinaryPayload();
  • Return Type

    (byte[] | error)
  • The message payload as a byte[] or else an error in case of errors

getFormParams

()

returns map<string> | error

Retrieves the form parameters from the content delivery request as a map.

 map<string>|error result = notification.getFormParams();
  • Return Type

    (map<string> | error)
  • The form params as a map or else an error in case of errors