feat(envelopes): support multiple response types with shared extension methods#213
Merged
j-d-ha merged 39 commits intoDec 15, 2025
Conversation
- Updated handler to utilize `ApiGatewayResponseEnvelopes` for dual response types. - Added support for bad request responses with `ErrorDetails`. - Introduced utility methods (`Ok`, `BadRequest`) for response creation. - Extended JSON serialization to include `ErrorDetails`.
…ewayResult` - Updated all references from `ApiGatewayResponseEnvelope` to `ApiGatewayResult`. - Renamed test classes and methods to align with the new type name. - Adjusted extension methods in `Program.cs` to work with `ApiGatewayResult`. - Simplified response creation to use new naming conventions. - Enhanced JSON serialization logic to accommodate updated class structure.
- Updated `LocalDevTasks.yml` to include a `--config-storage-path` option for the lambda test tool. - Added a default API Gateway request example in `lambda_test_tool/SavedRequests`.
- Added `Microsoft.AspNetCore.Http` reference to project file for API Gateway use cases. - Updated `Directory.Packages.props` with version `2.3.0` for consistent dependency management.
…velope` to `ApiGatewayResult` - Renamed `ApiGatewayResponseEnvelope` to `ApiGatewayResult` across the project for consistency. - Updated test class and method names to align with the new naming convention. - Adjusted logic in tests and production code to work with the renamed classes. - Introduced a new `ApiGatewayResult` file for improved structure and clarity. - Removed `ApiGatewayResponseEnvelope` related artifacts and references.
…sions - Streamlined handler implementation in `Program.cs` for better clarity. - Removed redundant `#region` and unused import statements. - Eliminated `ApiGatewayResultExtensions` to reduce duplication. - Enhanced response handling with header support in `ApiGatewayResult.Ok`. - Adjusted JSON serialization types to match updated logic.
…ode factories - Added factory methods for various status codes, including `NoContent`, `Unauthorized`, `NotFound`, `Conflict`, and `UnprocessableEntity`. - Updated existing methods to improve consistency by renaming `Status` to `StatusCode`. - Enhanced readability with categorized comments for status code methods.
…piGatewayResult` - Introduced `Created()` and `Created<T>(T bodyContent)` factory methods to handle `201 Created`. - Updated comments for better categorization and consistency with status code methods.
j-d-ha
force-pushed
the
feature/#212-support-multiple-response-types-with-same-envelope-base
branch
from
December 14, 2025 22:38
b3b0844 to
958bbf9
Compare
…y.Packages.props - Added `Microsoft.AspNetCore.Http` version `2.3.0` to support enhanced HTTP scenarios. - Ensured consistent dependency tracking in `Directory.Packages.props`.
…`ApiGatewayResult` - Changed namespace from `AwsLambda.Host.Envelopes.ApiGateway` to `MinimalLambda.Envelopes.ApiGateway`. - Replaced `AwsLambda.Host.Options` with `MinimalLambda.Options` for consistency.
…e handling - Updated `ApiGatewayResult` to implement `IHttpResult<ApiGatewayResult>` for generalized usage. - Replaced multiple factory methods with a single generalized static factory method. - Removed redundant status code-specific static methods for streamlined extensibility. - Introduced `IHttpResult` interface to standardize HTTP response contract. - Added support for reusable status code handling with `BaseHttpResultExtensions` and `HttpResultExtensions`. - Simplified implementation and enhanced flexibility for custom HTTP responses in API Gateway.
…t tool command - Updated `LocalDevTasks.yml` to include `--config-storage-path` for improved configurability.
…t methods from `ApiGatewayResult` - Added `ApiGatewayV2Result` to support AWS HTTP API Gateway v2 response handling. - Removed redundant methods and comments from `ApiGatewayResult` for cleaner implementation. - Updated `IHttpResult` interface with extended HTTP response properties. - Introduced extensions for header handling with `UpdateHttpResultExtensions`. - Simplified and streamlined codebase for improved maintainability and flexibility.
- Created `MinimalLambda.Envelopes` project targeting `net8.0`, `net9.0`, and `net10.0`. - Enabled nullable reference types, implicit usings, and preview language features. - Configured project for NuGet package generation with metadata placeholders. - Added `README.md` for documentation and included it in the package. - Integrated the new project into `MinimalLambda.sln`.
…handling - Moved `BaseHttpResultExtensions`, `HttpResultExtensions`, and `UpdateHttpResultExtensions` into separate files for modularity. - Revamped `ApiGatewayV2Result` to improve response handling with added flexibility. - Updated `MinimalLambda.Envelopes.ApiGateway` and project references to align with changes. - Added `Microsoft.AspNetCore.Http.Abstractions` package for HTTP helper methods and integrations. - Removed duplicate or redundant logic from `IHttpResult`.
…ctory.Packages.props` - Removed unused `Microsoft.AspNetCore.Http` package (version `2.3.0`) for dependency cleanup. - Ensured all references to this package were unnecessary before removal.
…omization - Added new `AlbResult` class for Application Load Balancer response handling. - Implemented `Configure` method in `ApiGatewayResult` and `ApiGatewayV2Result` for customizations. - Updated `IHttpResult` interface with a new `Configure` method. - Added `MinimalLambda.Envelopes` project reference to `MinimalLambda.Envelopes.Alb`. - Improved examples with `Configure` usage for custom headers and multi-value headers.
…result classes - Updated `Configure` to `Customize` in `ApiGatewayResult`, `ApiGatewayV2Result`, and `AlbResult`. - Adjusted `IHttpResult` interface to use `Customize` method instead of `Configure`. - Modified examples to reflect the method name change for better clarity and intent.
- Deleted `UpdateHttpResultExtensions.cs` as it is no longer used or required. - Simplified the codebase by removing unnecessary extension methods for headers and content types.
- Added XML documentation to `HttpResultExtensions` for method clarity and usability. - Provided summaries, parameter descriptions, and return value details for all HTTP status code methods. - Updated `BaseHttpResultExtensions` with XML comments for factory methods. - Enhanced `IHttpResult` interface with comprehensive XML documentation for properties and methods.
…reate` methods - Added `inheritdoc` XML documentation for `Customize` method in `ApiGatewayResult`, `ApiGatewayV2Result`, and `AlbResult`. - Applied `inheritdoc` XML documentation for `Create` method in all affected result classes. - Improved code clarity with consistent use of XML comments.
- Added detailed XML summaries and remarks to `ApiGatewayResult`, `ApiGatewayV2Result`, and `AlbResult`. - Improved clarity by explaining usage scenarios for each result class. - Enhanced API documentation for better usability and maintainability.
- Removed `Customize` method from `ApiGatewayResult`, `ApiGatewayV2Result`, and `AlbResult`. - Simplified `IHttpResult` interface by excluding `Customize` method. - Refactored `BaseHttpResultExtensions` to provide `Customize` functionality as an extension method. - Updated namespaces in all affected files for consistency with the project structure.
….Events` - Included `MinimalLambda.Envelopes` namespace in the example project for envelope handling. - Enhanced `examples/MinimalLambda.Example.Events/Program.cs` with additional import for functionality consistency.
…meters - Removed the `body` parameter from all `Create` method overloads in result classes. - Updated `IHttpResult` interface and implementations to reflect the changes. - Refactored `BaseHttpResultExtensions` to align with streamlined method signatures. - Improved overall code readability and reduced unnecessary complexity.
…used extension methods - Deleted `IHttpResult2<TSelf>` as it was not referenced or utilized in the project. - Removed unused `MyExtension` class and its `Create` extension method. - Simplified `IHttpResult` by excluding unnecessary extensions and duplicate abstractions.
- Updated project file with a meaningful package description. - Added a comprehensive `README.md` for `MinimalLambda.Envelopes` package. - Included usage information, documentation links, and related package details.
…E files - Updated multiple README files to include references to the `MinimalLambda.Envelopes` package. - Added links to the NuGet package and download badges for consistency and accessibility. - Improved documentation to ensure comprehensive package visibility across projects.
…ult` documentation to README - Updated `MinimalLambda.Envelopes.Alb` README with details on `AlbResult` class and its fluent API. - Updated `MinimalLambda.Envelopes.ApiGateway` README with details on `ApiGatewayResult` and `ApiGatewayV2Result` classes. - Highlighted usage scenarios, response methods, and customization options. - Added code samples and guidance for registering serializers with multiple result types.
…package features - Included a comprehensive explanation of the `MinimalLambda.Envelopes` infrastructure package. - Added documentation for the Response Builder API with usage examples and supported result classes. - Detailed AOT serializer configuration with examples for registering envelope and result types. - Highlighted scenarios for using result classes vs. envelopes directly.
…s` references - Added `MinimalLambda.Envelopes` to the installation guide table with usage scenarios. - Updated example code to use the streamlined `ApiGatewayResult.Ok` response builder. - Included NuGet package badge and download count for `MinimalLambda.Envelopes` in the index.
- Updated `Directory.Build.props` to reflect the new version 2.0.0-beta.7.
- Added tests for `StatusCode`, `Text`, and `Json` methods to verify result creation behavior. - Verified default headers, content types, and response body generation in tests. - Implemented a test for `Customize` extension to ensure property modification and chaining. - Utilized `AutoFixture` for generating test payloads and validated serialized responses. chore(project): update test project settings and language version - Updated `MinimalLambda.Envelopes.UnitTests.csproj` to use `LangVersion=preview`.
- Implemented tests for various result types: `Ok`, `Created`, `NoContent`, `BadRequest`, and more. - Verified response behavior, including status codes, headers, and JSON body content. - Utilized `AutoFixture` for generating test payloads to ensure test repeatability. - Ensured compatibility with the `AlbResult` response builder and `EnvelopeOptions`.
- Implemented tests for `Accepted`, `MovedPermanently`, `Found`, and `Forbidden` result types. - Verified response behavior, including status codes, headers, and JSON body content. - Added support for testing results with and without body content, including `Location` header checks. - Utilized `AutoFixture` for generating test payloads and validated JSON serialization behavior.
j-d-ha
marked this pull request as ready for review
December 15, 2025 12:33
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #213 +/- ##
==========================================
+ Coverage 88.09% 88.31% +0.22%
==========================================
Files 122 127 +5
Lines 2864 3013 +149
Branches 334 337 +3
==========================================
+ Hits 2523 2661 +138
- Misses 211 219 +8
- Partials 130 133 +3
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
- Added `Create` methods to `ApiGatewayResult`, `ApiGatewayV2Result`, and `AlbResult` classes. - Simplified wrapping response envelopes into result objects with type parameter support. - Improved API documentation with XML comments for new methods. feat(tests): add unit tests for `Create` methods in result classes - Implemented unit tests for `ApiGatewayResult.Create`, `ApiGatewayV2Result.Create`, and `AlbResult.Create`. - Verified correct status codes, headers, and payload handling with different envelopes. - Ensured `IsBase64Encoded` property and header presence are properly validated in tests.
- Simplified method summary to clarify strongly typed body usage. - Removed redundant remarks for clearer documentation format.
…-with-same-envelope-base
|
j-d-ha
deleted the
feature/#212-support-multiple-response-types-with-same-envelope-base
branch
December 15, 2025 14:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



🚀 Pull Request
📋 Summary
This PR introduces a unified HTTP result abstraction (
IHttpResult<TSelf>) that enables shared extension methods across ALB, API Gateway v1, and API Gateway v2 response types. By leveraging C# 14's extension blocks, developers can now use the same fluent API (.Ok(),.Created(),.NotFound(), etc.) across all three Lambda HTTP integration types.Key Changes:
IHttpResult<TSelf>interface as a common contract for HTTP responsesBaseHttpResultExtensionswith core factory methods (StatusCode,Text,Json,Customize)HttpResultExtensionswith convenience methods for common HTTP status codes (200, 201, 400, 404, 500, etc.)AlbResult,ApiGatewayResult, andApiGatewayV2Resultto implementIHttpResult<TSelf>Benefits:
✅ Checklist
🧪 Related Issues or PRs
Closes #212
💬 Notes for Reviewers
The use of C# 14 extension blocks (
extension<THttpResult>(IHttpResult<THttpResult>)) is intentional and correct syntax. This enables the extension methods to be callable on the interface while returning the concrete type for fluent chaining.All three HTTP result types (
AlbResult,ApiGatewayResult,ApiGatewayV2Result) now share the same extension methods, eliminating the need for duplicate implementations.