Using args
Pass JSON Args into a function from its instance and read them at runtime to change behavior without editing code.
Read a value from the Args of the function instance instead of hardcoding it in the function. Use this pattern when the same code runs on several instances and only a few values change between them, such as an identifier, a feature flag, or a destination hostname.
The Args set on the function instance that runs this code:
How it works
The fetch handler reads event.args.value and passes it to handleRequest, which returns that value in the body of a new Response, along with a custom header set through new Headers([...]) and an explicit status: 200. The value key comes from the JSON object above, so changing that object changes what the function returns.
Args are not part of the code. You set them on the function instance that binds the function to an application or a firewall, which is why the same function can behave differently on each instance without being edited or redeployed. How it works covers the rest of the chain, from the function to the instance to the Rules Engine rule that runs it.