src/builder.js
/**
     * Build a CloudEvent instance from the given arguments,
     * useful for simplify plugin hooks.
     * If plugin flag 'includeRedundantAttributes' is enabled,
     * some redundant attributes will be added to data.
     * Note that some config options for builders are used here.
     *
     * @param {!string} hookName the name of the hook
     * @param {!object} request the request
     * @param {object} reply the reply
     * @param {object} payload the payload
     * @return {object} the CloudEvent instance
     * @private
     */
Build a CloudEvent instance from the given arguments,
useful for simplify plugin hooks.
If plugin flag 'includeRedundantAttributes' is enabled,
some redundant attributes will be added to data.
Note that some config options for builders are used here.


Build a CloudEvent instance from the given arguments useful for simplify plugin hooks . If plugin flag ' includeRedundantAttributes ' is enabled some redundant attributes will be added to data . Note that some config options for builders are used here .
buildCloudEventForHook (hookName, request, reply, payload) {
      if (!hookName || !request) {
        throw new Error('Illegal arguments: mandatory argument undefined or null')
      }
      const ceData = {
        request: this.buildRequestDataForCE(request),
        reply: (reply === null) ? undefined : this.buildReplyDataForCE(reply),
        payload
      }
      if (includeRedundantAttributes !== null && includeRedundantAttributes === true) {
        ceData.id = request.id
        ceData.timestamp = CloudEventTransformer.timestampToNumber()
      }
      const ce = new CloudEvent(idGenerator.next().value,
        `${baseNamespace}.${hookName}`,
        this.buildSourceUrl(request.req.url),
        ceData,
        cloudEventOptions,
        cloudEventExtensions
      )
      return ce
    }
buildCloudEventForHook ( hookName , request , reply , payload ) { if ( ! hookName || ! request ) { throw new Error ( 'Illegal arguments: mandatory argument undefined or null' ) } const ceData = { request : this . buildRequestDataForCE ( request ) , reply : ( reply === null ) ? undefined : this . buildReplyDataForCE ( reply ) , payload } if ( includeRedundantAttributes !== null && includeRedundantAttributes === true ) { ceData . id = request . id ceData . timestamp = CloudEventTransformer . timestampToNumber ( ) } const ce = new CloudEvent ( idGenerator . next ( ) . value , ` ${ baseNamespace } ${ hookName } ` , this . buildSourceUrl ( request . req . url ) , ceData , cloudEventOptions , cloudEventExtensions ) return ce }
Build a CloudEvent instance from the given arguments,
 useful for simplify plugin hooks.
Build a CloudEvent instance from the given arguments useful for simplify plugin hooks .