Sample Function

Another plain forwarder

// Standard Express style HTTP sync function
export const tryKnative = (req, res) => {
  res.send(`Hello, ${req.query.u || 'World'}!`);
};

// OpenFunction standard function which could 
// set bridge between sync and async function
export const tryKnativeAsync = async (ctx, data) => {
  console.log('Data received: %o', data);

  // Forward HTTP body to Dapr outputs
  await ctx.send(data);

  // Send something back as HTTP response 
  // when necessary
  // ctx.res.send(data);
};

Remember to build the function, either when applying Function CR manifest or directly via Pack CLI tool

Sample CR Manifest

Check out full content in http-trigger.yml

spec:
  image: '<image-repo>/<image-name>:<image-tag>'
  serving:
    runtime: knative
    params:
      FUNCTION_TARGET: tryKnativeAsync
      FUNCTION_SIGNATURE_TYPE: openfunction
    outputs:
      - name: mqtt-output
        component: mqtt-out
        operation: create
    bindings:
      mqtt-out:
        type: bindings.mqtt
        version: v1
        metadata:
          - name: consumerID
            value: '{uuid}'
          - name: url
            value: tcp://admin:public@emqx:1883
          - name: topic
            value: out