Replies: 2 comments
-
At the moment, functions with the route attributes cannot have generics. This may be relaxed in the future, but even then only concrete routes can be mounted - so your mount would need to look something like |
Beta Was this translation helpful? Give feedback.
0 replies
-
See also #1570 for why this likely doesn't make sense. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to set up a request handler that will only fire if the request has data that parses properly. This parsing is being done by a third party library that I do not control, and returns a generic struct.
With non-generic structs, I have had luck doing something like
and then implementing
FromData
and so on. This is really great.However, although I can implement a
ThingGuard<E>(Thing<E>)
, I can't actually use it in a route.Example code:
The error I get is
Is there a way to do this?
The obvious alternative is to create a request guard that doesn't store the parse results, thus getting around the requirement to have the generic struct that's causing the problem - then the request would be type safe (yay!) but would have to redo parsing work (boo).
A way for a request guard to communicate data without storing it like this would also probably solve my problem.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions