@cldn/web-ts
Version:
Class-based Node.js web server
19 lines (18 loc) • 575 B
TypeScript
import { Request } from "../Request.js";
import { Response } from "../response/Response.js";
/**
* A route that can handle HTTP requests.
*/
export interface Route<A> {
/**
* Handles an incoming HTTP request and returns a response.
* @param req The request to handle.
* @return The response generated by handling the request.
*/
handle(req: Request<A>): Promise<Response<A>>;
/**
* Determines whether this route should/can handle the given request.
* @param req The request to check.
*/
match(req: Request<A>): boolean;
}