Appco.ServiceProtocol
1.0.0
See the version list below for details.
dotnet add package Appco.ServiceProtocol --version 1.0.0
NuGet\Install-Package Appco.ServiceProtocol -Version 1.0.0
<PackageReference Include="Appco.ServiceProtocol" Version="1.0.0" />
<PackageVersion Include="Appco.ServiceProtocol" Version="1.0.0" />
<PackageReference Include="Appco.ServiceProtocol" />
paket add Appco.ServiceProtocol --version 1.0.0
#r "nuget: Appco.ServiceProtocol, 1.0.0"
#:package Appco.ServiceProtocol@1.0.0
#addin nuget:?package=Appco.ServiceProtocol&version=1.0.0
#tool nuget:?package=Appco.ServiceProtocol&version=1.0.0
Appco.ServiceProtocol
A library for standardized service responses in .NET applications, providing consistent status and content handling for API and service layers.
Installation
Install via NuGet Package Manager:
Install-Package Appco.ServiceProtocol
Or using the .NET CLI:
dotnet add package Appco.ServiceProtocol
Requirements
- .NET 9 or later
Usage
Import the namespace in your service or controller:
using Appco.ServiceProtocol;
Exemples
// Example 1: Internal error response without content
var internalErrorResponse = InternalError("An unexpected error occurred.");
// internalErrorResponse.Status is StatusInternalError, Message = "An unexpected error occurred."
// Example 2: Internal error response with content
var internalErrorWithContent = InternalError("Database failure.", "Error details here");
// internalErrorWithContent.Status is StatusInternalError, Message = "Database failure."
// internalErrorWithContent.Content = "Error details here"
// Example 3: Not found response
var notFoundResponse = NotFound("User not found.");
// notFoundResponse.Status is StatusNotFound, Message = "User not found."
// Example 4: Not found response with content
var notFoundWithContent = NotFound("Order not found.", 12345);
// notFoundWithContent.Status is StatusNotFound, Message = "Order not found."
// notFoundWithContent.Content = 12345
// Example 5: Success response (OK)
var okResponse = Ok();
// okResponse.Status is StatusOk, Message = "Ok."
// Example 6: Success response (OK) with custom message
var okWithMessage = Ok("Operation completed successfully.");
// okWithMessage.Status is StatusOk, Message = "Operation completed successfully."
// Example 7: Success response (OK) with content
var okWithContent = Ok("Data loaded.", "Sample data");
// okWithContent.Status is StatusOk, Message = "Data loaded."
// okWithContent.Content = "Sample data"
// Example 8: Created response
var createdResponse = Created("Resource created.");
// createdResponse.Status is StatusCreated, Message = "Resource created."
// Example 9: Updated response with content
var updatedWithContent = Updated("Resource updated.", "Updated value");
// updatedWithContent.Status is StatusUpdated, Message = "Resource updated."
// updatedWithContent.Content = "Updated value"
// Example 10: Deleted response
var deletedResponse = Deleted("Resource deleted.");
// deletedResponse.Status is StatusDeleted, Message = "Resource deleted."
License
This project is licensed under the MIT License.
Support
For questions or issues, please open an issue on the repository or contact the maintainers.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.