qol(http/route): typings and handler signature #5884
Labels
enhancement
New feature or request
feedback welcome
We want community's feedback on this issue or PR
good first issue
Good for newcomers
http
PR welcome
A pull request for this issue would be welcome
The
Handler
interface is currently defined as:std/http/route.ts
Lines 14 to 18 in 94a7e1b
But I feel like people users using this API would most likely prefer to have
URLPatternResult
as second argument andDeno.ServeHandlerInfo
as third one.Reasoning is that people using this API will almost always want to retrieve their route params, but the usage of
Deno.ServeHandlerInfo
is less likely. Also since the url/method is already checked by theroute()
function, it is also common not have have use forRequest
, so you may end up with:Which is less elegant than:
I understand it was done to be compatible with regular handlers, but maybe
route()
could support an union of both.Also the typing
params?: URLPatternResult | null,
seems incorrect (at least for non-default handler), because the result is checked before being passed down to handler:std/http/route.ts
Lines 93 to 96 in 94a7e1b
So users need to add an uneeded
!.
since to avoid typing issuesThe text was updated successfully, but these errors were encountered: