Router Module

Module for efficient HTTP routing with path parameter support

Types

Type Description

RouteEntry

Route entry with pattern and handler

RoutePattern

Represents a parsed route pattern

RouteSegment

Represents a segment in a route pattern

Router

Router state containing all registered routes

RouterBuilder

Builder for creating routers with a clean syntax

ScopeBuilder

Scope builder for route prefixes

Functions and values

Function or value Description

addRoute router pattern methods handler

Full Usage: addRoute router pattern methods handler

Parameters:
Returns: Router

Add a route to the router

router : Router
pattern : string
methods : HttpMethod list
handler : WebPart
Returns: Router

empty ()

Full Usage: empty ()

Parameters:
    () : unit

Returns: Router

Create an empty router

() : unit
Returns: Router

matchPattern pattern path

Full Usage: matchPattern pattern path

Parameters:
Returns: (string * string) list option

Match a request path against a route pattern and extract parameters

pattern : RoutePattern
path : string
Returns: (string * string) list option

parsePattern pattern

Full Usage: parsePattern pattern

Parameters:
    pattern : string

Returns: RoutePattern

Parse a route pattern string into segments

pattern : string
Returns: RoutePattern

route methods path handler

Full Usage: route methods path handler

Parameters:
Returns: HttpMethod list * string * WebPart

Helper to create a route for multiple HTTP methods

methods : HttpMethod list
path : string
handler : WebPart
Returns: HttpMethod list * string * WebPart

routeParam name ctx

Full Usage: routeParam name ctx

Parameters:
Returns: string option

Get a route parameter from context

name : string
ctx : HttpContext
Returns: string option

router

Full Usage: router

Returns: RouterBuilder

Computation expression for building routers

Returns: RouterBuilder

scope prefix

Full Usage: scope prefix

Parameters:
    prefix : string

Returns: ScopeBuilder

Create a scope with a route prefix

prefix : string
Returns: ScopeBuilder

tryRoute router ctx

Full Usage: tryRoute router ctx

Parameters:
Returns: Async<HttpContext option>

Try to match and execute a route

router : Router
ctx : HttpContext
Returns: Async<HttpContext option>