chridou / http-api-problem

A problem type to be returned by HTTP APIs
Apache License 2.0
53 stars 12 forks source link

Allow internal values in `HttpApiProblem` #40

Closed damooo closed 1 year ago

damooo commented 2 years ago

Currently any custom values added to a problem will be serialized into response. This may be problem, if we want to use them as error extensions in middleware, and ignore in final response. It would be helpful, if there is a convention for private values, or a method to delete them directly.

chridou commented 2 years ago

Hi!

I will add the request extensions from the http crate to the ApiError to fulfill this use case. For the HttpApiProbem itself i will expose the fields mutably

chridou commented 2 years ago

There is a draft PR (WIP): https://github.com/chridou/http-api-problem/pull/41

damooo commented 1 year ago

Hello @chridou, though http::extensions allows for extensibility, it doesn't fit well in use case of extensible errors, where we normally require record-like extensions. I.e. kv pairs with multiple keys having same value type.

Instead i suggest to use typemap_rev for allowing such use case with typed keys. This will then be breeze to practical extensible errors.

damooo commented 1 year ago

Now new version is available on crates.io. Thanks for great work @chridou