Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[on hold] BREAKING(http/unstable): switch params and info args in Handler in route() for more conveniency #6094

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions http/unstable_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
export type Handler = (
request: Request,
params?: URLPatternResult,
info?: Deno.ServeHandlerInfo,
params?: URLPatternResult | null,
) => Response | Promise<Response>;

/**
Expand Down Expand Up @@ -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/*" }),
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions http/unstable_route_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Loading