File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Request } from "../Request.js" ;
2+ import { Response } from "../response/index.js" ;
3+ import { Route } from "./Route.js" ;
4+
5+ /**
6+ * Routes requests based on HTTP method and path.
7+ */
8+ export abstract class EndpointRoute implements Route {
9+ private readonly method : Request . Method ;
10+ private readonly path : string ;
11+
12+ /**
13+ * @param method The required HTTP method to match.
14+ * @param path The request URL path to match.
15+ */
16+ protected constructor ( method : Request . Method , path : string ) {
17+ this . method = method ;
18+ this . path = path ;
19+ }
20+
21+ public match ( req : Request ) : boolean {
22+ return req . method === this . method && req . url . pathname === this . path ;
23+ }
24+
25+ public abstract handle ( req : Request ) : Response | Promise < Response > ;
26+ }
You can’t perform that action at this time.
0 commit comments