publish(pub)

    Called when a client wants to publish a message. It provides a single argument pub which is a Lua table containing context of the publish request. The function is free to modify the request however it needs, but it must return it (modified or not) to the server or the publish request will be rejected with a 403 Forbidden error and the message will not be delivered to any subscribers.

    NOTE: Changes to the inner req table will not be preserved.

    function publish(pub)
      -- The `pub` table looks like
      {
        req = {
          headers = {
            ["content-type"] = "application/json",
            ["content-length"] = "24",
            accept = "*/*",
            host = "127.0.0.1:1983",
            ["user-agent"] = "curl/8.7.1"
          },
          query = "",
          path = "/sse",
          addr = {
            ip = "127.0.0.1",
            port = 59615
          },
          method = "POST"
        },
        msg = {
          data = "Hello, World"
        }
      }
      
      -- The function is free to modify this table however it needs, but it
      -- must return it to the server or the message will be rejected.
      return pub
    end