mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
BREAKING(http): switch params
and info
args in Handler
for more conveniency
This commit is contained in:
parent
065296ca5a
commit
4cd2e8c760
@ -13,8 +13,8 @@
|
||||
*/
|
||||
export type Handler = (
|
||||
request: Request,
|
||||
params?: URLPatternResult,
|
||||
info?: Deno.ServeHandlerInfo,
|
||||
params?: URLPatternResult | null,
|
||||
) => Response | Promise<Response>;
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ export interface Route {
|
||||
* },
|
||||
* {
|
||||
* pattern: new URLPattern({ pathname: "/users/:id" }),
|
||||
* handler: (_req, _info, params) => new Response(params?.pathname.groups.id),
|
||||
* handler: (_req, params) => new Response(params?.pathname.groups.id),
|
||||
* },
|
||||
* {
|
||||
* pattern: new URLPattern({ pathname: "/static/*" }),
|
||||
@ -102,7 +102,7 @@ export function route(
|
||||
? route.method.includes(request.method)
|
||||
: request.method === (route.method ?? "GET"))
|
||||
) {
|
||||
return route.handler(request, info, match);
|
||||
return route.handler(request, match, info);
|
||||
}
|
||||
}
|
||||
return defaultHandler(request, info);
|
||||
|
@ -10,8 +10,7 @@ const routes: Route[] = [
|
||||
},
|
||||
{
|
||||
pattern: new URLPattern({ pathname: "/users/:id" }),
|
||||
handler: (_request, _info, params) =>
|
||||
new Response(params?.pathname.groups.id),
|
||||
handler: (_request, params) => new Response(params?.pathname.groups.id),
|
||||
},
|
||||
{
|
||||
pattern: new URLPattern({ pathname: "/users/:id" }),
|
||||
|
Loading…
Reference in New Issue
Block a user