Hi, first I just want to say that I really love this framework the more I use it.
I'm really intrigued by IETF's RFC 7807, and I'm thinking about trying to add those fields to some existing twirp endpoints.
The best solution I can find at the moment would be to extend twirp.Error add an Interceptor that tries to err.WithMeta a bunch of times.
That doesn't get me to actually meeting the RFC 7807 spec, since these fields wouldn't be at the top level, but it'd probably be totally fine for now.
I'm curious though -- is there a way to add custom fields to the top level of a twirp error response? It seems like that'd require supporting a Final func(context.Context, string, error) string middleware that receives both the raw bytes of the almost-final response as well as the err returned by the method handler and then returns a potentially modified body.
Hi, first I just want to say that I really love this framework the more I use it.
I'm really intrigued by IETF's RFC 7807, and I'm thinking about trying to add those fields to some existing twirp endpoints.
The best solution I can find at the moment would be to extend
twirp.Error
add an Interceptor that tries toerr.WithMeta
a bunch of times.That doesn't get me to actually meeting the
RFC 7807
spec, since these fields wouldn't be at the top level, but it'd probably be totally fine for now.I'm curious though -- is there a way to add custom fields to the top level of a twirp error response? It seems like that'd require supporting a
Final func(context.Context, string, error) string
middleware that receives both the raw bytes of the almost-final response as well as theerr
returned by the method handler and then returns a potentially modified body.