tide icon indicating copy to clipboard operation
tide copied to clipboard

Expose the matched route as an extension on the request

Open kyrias opened this issue 3 years ago • 2 comments

I considered adding it directly to the Request struct, though now I'm not sure anymore why I didn't, haha. I guess this PR is more of an RFC though. I would be happy with either implementation, but I do have a need for getting the route.


Edit: I remembered now why I chose not to add it to the Request struct which is that it feels cleaner to have the Request struct only deal with the actual client-submitted request, and the concept of a matched route is purely a server-side abstraction.

But since the Request already contains the list of captured route parameters I guess this point is a bit moot. Though I guess if this separation was wanted it wouldn't be unreasonable to remove the route_params struct member and turn that into an extension struct as well.

kyrias avatar Sep 05 '22 20:09 kyrias

I think this is good, but it could just be a method on tide::Request IMO.

Fishrock123 avatar Sep 08 '22 06:09 Fishrock123

Reasonable. I've made the struct internal to the crate and added a method to get the extension now.

kyrias avatar Sep 08 '22 08:09 kyrias