DocumentationFundamentals
Accessing metadata
Accessing metadata from Webhook Relay Functions
It can be useful to access metadata from the function. For example, you can access the bucket, input and output names or the IDs directly from the function. This way you can build more complex functions that can be used in different scenarios.
Accessing metadata
You can access the metadata from the function using the r.Metadata
table.
Available metadata
Metadata | Description |
---|---|
bucket_id | The ID of the bucket |
bucket_name | The name of the bucket |
input_id | The ID of the input |
input_name | The name of the input |
output_id | The ID of the output |
output_name | The name of the output |
output_url | The URL of the output |
Example function deciding based on bucket name
Here's an example accessing Bucket name from within the function:
local http = require("http")
local bucket_name = r.Metadata["bucket_name"]
if bucket_name == "first-bucket" then
-- do something
response, err = http.request("GET", "https://company-a.com")
if err then error(err) end
-- exit from function
return
end
if bucket_name == "second-bucket" then
-- do something
response, err = http.request("GET", "https://company-b.com")
if err then error(err) end
-- exit from function
return
end