Table of Contents

Class WorkerRoute

Namespace
Cloudflare.NET.Workers.Models
Assembly
Cloudflare.NET.dll

Represents a Worker route that maps URL patterns to Worker scripts.

Routes determine which requests are handled by which Workers based on URL pattern matching.

public record WorkerRoute : IEquatable<WorkerRoute>
Inheritance
WorkerRoute
Implements
Inherited Members

Examples

Pattern examples:

  • example.com/* - All paths on domain
  • *.example.com/api/* - API paths on subdomains
  • example.com/static/* - Static asset paths

Constructors

WorkerRoute(string, string, string?)

Represents a Worker route that maps URL patterns to Worker scripts.

Routes determine which requests are handled by which Workers based on URL pattern matching.

public WorkerRoute(string Id, string Pattern, string? Script = null)

Parameters

Id string

Unique route identifier.

Pattern string

URL pattern this route matches. Supports wildcards: * matches any characters.

Script string

Name of the Worker script to execute for matching requests. Can be null to disable Worker for matching routes.

Examples

Pattern examples:

  • example.com/* - All paths on domain
  • *.example.com/api/* - API paths on subdomains
  • example.com/static/* - Static asset paths

Properties

Id

Unique route identifier.

[JsonPropertyName("id")]
public string Id { get; init; }

Property Value

string

Pattern

URL pattern this route matches. Supports wildcards: * matches any characters.

[JsonPropertyName("pattern")]
public string Pattern { get; init; }

Property Value

string

Script

Name of the Worker script to execute for matching requests. Can be null to disable Worker for matching routes.

[JsonPropertyName("script")]
public string? Script { get; init; }

Property Value

string