Skip to content

This NuGet package includes the Response class, which represents general purpose HTTP responses, used to standardize response generation and communication in APIs. Supported for .NET 7.0 and above.

License

Notifications You must be signed in to change notification settings

mustafasameturan/Mst.Response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mst.Response NuGet Package

Description

This package includes the Response class, which represents general purpose HTTP responses, used to standardize response generation and communication in APIs.

Installation

Install it via the NuGet package manager:

Install-Package Mst.Response

or via the .NET CLI:

dotnet add package Mst.Response

or you can use NuGet UI on your IDE.

Usage

  • Return success with generic data and status code.
    SampleDataModel sampleDataModel = new()
    {
       FullName = "Mustafa Samet Turan"
    };

    Response<SampleDataModel>.Success(sampleDataModel, 200);
  • Return success with only status code
    Response<NoDataModel>.Success(200);
  • Return success with message and status code.
    Response<NoDataModel>.Success("Entity created!", 204);
  • Return fail with one error message and status code.
    Response<NoDataModel>.Success("Entity not found!", 404);
  • Return fail with multiple error messages and status code.
    List<string> errorList = new()
    {
        new("Validation error!"),
        new("Validation error 2!"),
    };
        
    Response<SampleDataModel>.Fail(errorList, 400);

Contributing

Feel free to improve and comment! Thank you.

License

Mst.Response NuGet package is licensed under MIT license.

About

This NuGet package includes the Response class, which represents general purpose HTTP responses, used to standardize response generation and communication in APIs. Supported for .NET 7.0 and above.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages