Skip to content

Added ResultStatus.Accepted for HTTP 202 async processing support#246

Open
ramiabughazaleh wants to merge 1 commit intoardalis:mainfrom
ramiabughazaleh:main
Open

Added ResultStatus.Accepted for HTTP 202 async processing support#246
ramiabughazaleh wants to merge 1 commit intoardalis:mainfrom
ramiabughazaleh:main

Conversation

@ramiabughazaleh
Copy link

This pull request adds support for the HTTP 202 Accepted status to the Result pattern, allowing APIs to indicate that a request has been accepted for processing but not yet completed. The changes include updates to the core Result model, extension methods, ASP.NET Core integration, and corresponding unit tests to ensure correct behavior and status mapping.

Core Result Enhancements:

  • Added a new ResultStatus.Accepted value to the ResultStatus enum and updated the IsSuccess property to treat Accepted as a success status. (src/Ardalis.Result/ResultStatus.cs [1] src/Ardalis.Result/Result.cs [2]
  • Introduced static factory methods for creating Accepted results, both with and without a location value. (src/Ardalis.Result/Result.cs [1] src/Ardalis.Result/Result.Void.cs [2]
  • Added an IsAccepted extension method for checking if a result is accepted. (src/Ardalis.Result/IResultExtensions.cs src/Ardalis.Result/IResultExtensions.csR15-R19)

ASP.NET Core Integration:

  • Updated ActionResultExtensions and MinimalApiResultExtensions to handle Accepted results, including proper setting of the Location header when provided. (src/Ardalis.Result.AspNetCore/ActionResultExtensions.cs [1] src/Ardalis.Result.AspNetCore/MinimalApiResultExtensions.cs [2]
  • Mapped ResultStatus.Accepted to HTTP 202 in the default status map. (src/Ardalis.Result.AspNetCore/ResultStatusMap.cs src/Ardalis.Result.AspNetCore/ResultStatusMap.csR30)

Testing and Validation:

These changes make it easier to build APIs that follow RESTful conventions for long-running or asynchronous operations by providing first-class support for the 202 Accepted status throughout the result handling pipeline.

@ramiabughazaleh
Copy link
Author

Fixes #237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants