ardalis / Result

A result abstraction that can be mapped to HTTP response codes if needed.
MIT License
847 stars 100 forks source link

Add support for HttpStatusCode: Created to the ResultStatus mapping #196

Closed wtygibbs closed 1 day ago

wtygibbs commented 1 month ago

ResultStatusMap.AddDefaultMap() is missing the mapping for ResultStatus.Created.

I think this is an oversight because ResultStatusMap.AddDefaultMap()'s documentation says it adds default mapping for all known ResultStatus's.

Calling ResultExtensions.ToActionResult<T>(T Result) throws a System.Collections.Generic.KeyNotFoundException with the message:

The given key 'Created' was not present in the dictionary

  1. Is there a reason I don't know of for why Created is not in the mapping?
  2. Support for the Created HttpStatusCode should be added, or at least handle it and not throw an exception

If there is agreement on bullet point 2, I am open to working on it.

ardalis commented 1 month ago

No idea why I didn't include that before now. Feel free to submit a PR if you have time, thanks!🙏

Astenna commented 2 weeks ago

Can someone add required approval to the PR? I also unexpectedly found the mapping is missing

FarazFolio3 commented 2 weeks ago

Hello, Would like to use this as well can we get this merged please Thanks :)