1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

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>
This commit is contained in:
F.D.Castel
2021-10-11 17:04:49 -03:00
committed by GitHub
parent 156c684be6
commit 0d12eb7dc6
17 changed files with 370 additions and 21 deletions

View File

@ -0,0 +1,29 @@
---
name: CF_WORKER_ROUTE
parameters:
- pattern
- script
---
`CF_WORKER_ROUTE` uses the [Cloudflare Workers](https://developers.cloudflare.com/workers/)
API to manage [worker routes](https://developers.cloudflare.com/workers/platform/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 %}