dnscontrol/docs/_functions/domain/CF_WORKER_ROUTE.md
F.D.Castel 0d12eb7dc6
CLOUDFLAREAPI: Adds CF_WORKER_ROUTE (#1243)
* CLOUDFLAREAPI: Adds CF_WORKER_ROUTE.

- CLOUDFLAREAPI: Initial support for CF_WORKER_ROUTE.
- Put CF_WORKER_ROUTE behind a per-domain feature-flag.
- Adds Integration Test.
- Create Cloudflare workers for tests.
- Updates documentation.

* Workaround for updateWorkerRoute causing stack overflow.

* Sets AccountID.

* Updates to latest master (Thanks @tresni!).

* Removes $CLOUDFLAREAPI_ACCOUNTNAME.

* Add alltrue() filter and -cfworkers flag

* Final workers changes

* alltrue() should be implemented like other filters.
* Update documentation.

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
2021-10-11 16:04:49 -04:00

973 B

name parameters
CF_WORKER_ROUTE
pattern
script

CF_WORKER_ROUTE uses the Cloudflare Workers API to manage worker routes for a given domain.

If any CF_WORKER_ROUTE function is used then dnscontrol will manage all Worker Routes for the domain. To be clear: this means it will delete existing routes that were created outside of DNSControl.

WARNING: This interface is not extensively tested. Take precautions such as making backups and manually verifying dnscontrol preview output before running dnscontrol push.

This example assigns the patterns api.foo.com/* and foo.com/api/* to a my-worker script:

{% include startExample.html %} {% highlight js %} D("foo.com", .... , CF_WORKER_ROUTE("api.foo.com/", "my-worker"), CF_WORKER_ROUTE("foo.com/api/", "my-worker"), ); {%endhighlight%} {% include endExample.html %}