https://github.com/dahomey-technologies/dahomey.cbor.aspnetcore
Asp.Net Core Support for Dahomey.Cbor
https://github.com/dahomey-technologies/dahomey.cbor.aspnetcore
asp-net-core cbor cbor-library csharp dotnet rfc-7049 serialization
Last synced: 6 months ago
JSON representation
Asp.Net Core Support for Dahomey.Cbor
- Host: GitHub
- URL: https://github.com/dahomey-technologies/dahomey.cbor.aspnetcore
- Owner: dahomey-technologies
- License: mit
- Created: 2019-08-20T11:42:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T23:37:08.000Z (over 5 years ago)
- Last Synced: 2023-03-02T22:01:10.144Z (about 2 years ago)
- Topics: asp-net-core, cbor, cbor-library, csharp, dotnet, rfc-7049, serialization
- Language: C#
- Homepage:
- Size: 34.2 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dahomey.Cbor.AspNetCore
Asp.Net Core Support for [Dahomey.Cbor](https://github.com/dahomey-technologies/Dahomey.Cbor)
## Features
* Asp.net core 2.1, 2.2, 3.0 and 3.1 CBOR formatters## Setup
You can enable [Dahomey.Cbor](https://github.com/dahomey-technologies/Dahomey.Cbor) as a CBOR formatter in ASP.NET Core 2.1 or 2.2 by using the Nuget package [Dahomey.Cbor.AspNetCore](https://www.nuget.org/packages/Dahomey.Cbor.AspNetCore/). To enable it, add the extension method ``AddDahomeyCbor(CborOptions options = null)`` to the ``AddMvc()/AddControllers()`` call in ``ConfigureServices``### Asp.net core 2.x
```csharp
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
CborOptions options = new CborOptions();
services.AddMvc()
.AddDahomeyCbor(options);
}
```### Asp.net core 3.x
```csharp
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
CborOptions options = new CborOptions();
services.AddControllers()
.AddDahomeyCbor(options);
}
```### HTTP Headers
If an incoming HTTP request holds the following headers:
* ``Content-Type`` with the value ``application/cbor``: the Request body will be deserilized in CBOR.
* ``Accept`` with the value ``application/cbor``: the Response body will be serialized in CBOR.If the headers are missing, the default JSON formatters will be used.