Polhem.JsonRpc.AspNetCore
1.0.0
dotnet add package Polhem.JsonRpc.AspNetCore --version 1.0.0
NuGet\Install-Package Polhem.JsonRpc.AspNetCore -Version 1.0.0
<PackageReference Include="Polhem.JsonRpc.AspNetCore" Version="1.0.0" />
<PackageVersion Include="Polhem.JsonRpc.AspNetCore" Version="1.0.0" />
<PackageReference Include="Polhem.JsonRpc.AspNetCore" />
paket add Polhem.JsonRpc.AspNetCore --version 1.0.0
#r "nuget: Polhem.JsonRpc.AspNetCore, 1.0.0"
#:package Polhem.JsonRpc.AspNetCore@1.0.0
#addin nuget:?package=Polhem.JsonRpc.AspNetCore&version=1.0.0
#tool nuget:?package=Polhem.JsonRpc.AspNetCore&version=1.0.0
Polhem.JsonRpc.AspNetCore
A JSON-RPC 2.0 endpoint for ASP.NET Core, on System.Text.Json.
builder.Services.AddSingleton<IJsonRpcObjectFactory, AppObjectFactory>();
builder.Services.AddJsonRpcServer();
app.MapJsonRpc("/api");
// "Calculator.Add": the ProgId "Calculator" names the object, the action "Add" the method.
public sealed class AppObjectFactory : IJsonRpcObjectFactory
{
public object? CreateObject(string progId, JsonRpcRequestContext context) => progId switch
{
"Calculator" => new Calculator(),
_ => null,
};
}
public sealed class Calculator
{
// Callable because the parameter is AddRequest and the result AddResponse.
public AddResponse Add(AddRequest request) => new() { Sum = request.A + request.B };
}
A method name has the form ProgId.Action: the application's IJsonRpcObjectFactory creates the object for the
ProgId, and the action is a public instance method of it whose parameter is named {Action}Request and whose result
is named {Action}Response. Filters
(IJsonRpcFilter) run around every call, for authorization or for rewriting parameters and results. An MVC
controller can serve the endpoint too, through JsonRpcHttpHandler.HandleAsync(HttpContext).
Documentation and samples: https://github.com/polhem-dev/polhem-jsonrpc
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Polhem.JsonRpc.Server (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.