-
-
Notifications
You must be signed in to change notification settings - Fork 202
Unable to create a wrapper func that also requires the *http.Request object #811
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
Comments
I've noticed that slices and maps will be recursively processed ( Lines 442 to 447 in eb497ee
Lines 451 to 454 in eb497ee
Blended type to this:
type Blended[P, B any] struct {
RequestAware
Params []P
Body B
} This approach can capture the Lines 292 to 299 in eb497ee
To set the slice or the map, it requires the current slice/map value to be initialized with proper sizes, which is not likely to serve the toplevel type to contain further param definitions, as per:Lines 668 to 684 in eb497ee
Line 684 in eb497ee
It seems to be a dead end here. Which got me thinking that if there's a Lines 442 to 448 in eb497ee
`recursive:"true"` , could this problem be happily solved?And this will allow arbitary composing of input structures with generic types... while not changing any existing behaviours. |
With the change proposed by #813 , I can modify the type Blended[P, B any] struct {
RequestAware
Params P `recursive:"true"`
Body B
} And it works as expected. |
Kindly ping. |
Hi there, I'm trying to create a resuable wrapper function that can do some common logic against the
*http.Request
. Below is my attempt:In the above example, I'm struggling to get the Input value. The type
[I]
in my first registered handler, is like this:I can however successfully capture the
*http.Request
. Is it because that theI
is not embedded in theBlended
struct ? But there's no way to embed a generic type parameter currently AFAIK.Can someone please help me, guide me out of this storm, please! Thank you beforehand!
The text was updated successfully, but these errors were encountered: