serwist
Version:
A Swiss Army knife for service workers.
24 lines • 1.14 kB
TypeScript
import { Route } from "./Route.js";
import type { HTTPMethod } from "./constants.js";
import type { RouteHandler } from "./types.js";
/**
* A class that makes it easy to create a {@linkcode Route} object with a regular expression.
*
* For same-origin requests the `RegExp` only needs to match part of the URL. For
* requests against third-party servers, you must define a `RegExp` that matches
* the start of the URL.
*/
export declare class RegExpRoute extends Route {
/**
* If the regular expression contains
* [capture groups](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references),
* the captured values will be passed to the `params` argument.
*
* @param regExp The regular expression to match against URLs.
* @param handler A callback function that returns a `Promise` resulting in a `Response`.
* @param method The HTTP method to match the {@linkcode Route} against. Defaults to `GET`.
* against.
*/
constructor(regExp: RegExp, handler: RouteHandler, method?: HTTPMethod);
}
//# sourceMappingURL=RegExpRoute.d.ts.map