Ameling.BatchRequest
1.0.1
dotnet add package Ameling.BatchRequest --version 1.0.1
NuGet\Install-Package Ameling.BatchRequest -Version 1.0.1
<PackageReference Include="Ameling.BatchRequest" Version="1.0.1" />
paket add Ameling.BatchRequest --version 1.0.1
#r "nuget: Ameling.BatchRequest, 1.0.1"
// Install Ameling.BatchRequest as a Cake Addin #addin nuget:?package=Ameling.BatchRequest&version=1.0.1 // Install Ameling.BatchRequest as a Cake Tool #tool nuget:?package=Ameling.BatchRequest&version=1.0.1
BatchRequest
BatchRequest is NuGet package which opens up an endpoint within a Asp.Net Core application to make batch requests: multiple requests embedded within a single HTTP request. While REST API's are quite strong, sometimes lots of values have to be retrieved before proper UI can be shown. Launching multiple requests is definitely an option, but when the amount increases it is a good idea to bundle your requests to both make your UI code simpler and save some load on your server.
Configuration
To add batch requests to your application, call the IServiceCollection
extensions methond in ConfigureServices(IServiceCollection services)
:
public void ConfigureServices(IServicesCollection services)
{
// ..
services.AddBatchRequest();
// ..
}
This method optionally takes an Action<BatchRequestOptions>
parameter, to configure additional options:
- EnableEndpoint: Whether to enable the /api/batch endpoint. Defaults to true. When set to false, one can still get the
IBatchRequestService
through dependency injection. - RequestHost: The request host which is set in
HttpContext.Request
, which could be used identify whether the current request is being executed in the context of a batch request. Defaults tohttps://batchrequest
. - DefaultProtocol: The request protocol string which is set in
HttpContext.Request
. Defaults toBatchRequest
.
Making a batch request
Each request is identified by the following model:
{
"RelativeUri": "/api/batch", // The endpoint which has to be called on this server
"Method": "Get", // The method to execute the endpoint with. Can be one of Delete, Get, Head, Options, Patch, Post or Put. When omitted (or null), defaults to Get
"ContentType": "application/json", // The (optional) content type of the body which is posted
"Body": "{\"my\": \"json object\"}", // The body to post
"Base64Encoded": false // Whether the body is encoded with base64, for binary files. Defaults to false when omitted.
}
These objects are then put in an array, and if the endpoint is enabled can be posted to /api/batch
. The response of this endpoint will be an array of the response objects, where each index corresponds with the same request. A response object is defined as:
{
"StatusCode": 200, // the status code of the request
"ContentType": "application/json; charset=utf-8;", // the response content type
"Body": "5", // the response
"Base64Encoded": false, // Whether the body was encoded with base64
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.