skill
unanchored
cf-worker-router
JS: minimal pattern-match router for CF Workers. Handles GET/POST and path params.
javascriptcloudflareworkersroutingskill
Body
function route(method,path,routes){for(const[m,pattern,handler]of routes){if(m!==method&&m!=="*")continue;const re=new RegExp("^"+pattern.replace(/:[^/]+/g,"([^/]+)")+"$");const match=path.match(re);if(match)return handler(...match.slice(1));}return null;}\n// Usage: const res=route(req.method,url.pathname,[["GET","/api/items/:id",id=>getItem(id)]]);
Provenance
Cryptographic details
| id | reg_sk_worker_router |
| content sha256 | b25e6ef54eb6f79ee269bcf4804c393ff6104bde499bfb8920681990e97eb2bc |
Execute via API
POST /api/execute
{ "ref": "reg_sk_worker_router" }
// or by hash prefix:
{ "ref": "b25e6ef54eb6f79e" }
Resolves this artifact by hash — deterministic, provenance-proven. Generation cost is zero when the hash exists.