You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
typeDecodeFuncfunc(namestring, inputinterface{}, outVal reflect.Value) errortypeDecoderConfigstruct{
...// if defined, pass in Decoder.decode to get a new DecodeFunc.// Fallback to call Decoder.decode directly.DecodeMiddlewarefunc(DecodeFunc) DecodeFunc
}
With an example implementation for preserving time.Time as described in #191 (although this should probably be handled by default as well):
PS! As for what to do with the existing hook types, and functions, they would still work, but it would make sense (to me) to document them as deprecated; they really just do half the job, and they add complexity...
Implementation wise it's probably not exactly as straight-farward as to wrap the entireDecoder.decode, but rather, a sub-set of it. The middleware must of-course run recrusivly from the inner funciton, so the bit to replace, is probably the code here:
Put the switch-case inside a new function, and pass it to the middlware func before calling.
The lower bit with the meta-data update must still happen after. Figure out how to handle the addMetaKey Boolean.
Thanks for the suggestion. I believe everything you want to do would be possible by composing decode hooks using the new #183 PR (I saw you responded there as well). In general, I'm a fan of middleware, but the aforementioned PR fits the existing "shape" of this project so I wanted to give that a shot. Let me know if that doesn't solve things for you!
As shown by #191 and #115, it is not possible through the current hook system to specify override semantics because hooks only does pre-processing.
To my experience, middleware is always more powerful than hooks, because you can control the flow a lot better.
I think it would make sense to introduce a middleware for:
Example implementation stub:
With an example implementation for preserving
time.Time
as described in #191 (although this should probably be handled by default as well):The text was updated successfully, but these errors were encountered: