Allowing only POST requests through

How do I allow only POST requests through the input or output?

Often webhooks are sent as POST requests. However, sometimes you might be getting other requests to this endpoint (GET, PATCH, etc.), to filter them out, create a function:

if r.RequestMethod ~= "POST" then 
    -- request is not important, don't forward it
    r:StopForwarding()
    return
end 

And attach it to the output. Once added, POST requests will come through:

curl -X POST https://z2dc2rdlhajz826steaiig.hooks.webhookrelay.com

while PUT, GET and other request method webhooks:

curl -X POST https://z2dc2rdlhajz826steaiig.hooks.webhookrelay.com

will be filtered out:

Last updated