Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/giosil/netjsonrpc
Simple JSON-RPC protocol implementation based on ASP.NET Core project.
https://github.com/giosil/netjsonrpc
asp-net-core json-rpc json-rpc-api json-rpc-server json-rpc2
Last synced: 22 days ago
JSON representation
Simple JSON-RPC protocol implementation based on ASP.NET Core project.
- Host: GitHub
- URL: https://github.com/giosil/netjsonrpc
- Owner: giosil
- License: apache-2.0
- Created: 2020-07-28T08:36:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-11-09T09:15:43.000Z (about 1 year ago)
- Last Synced: 2024-11-07T06:17:59.674Z (2 months ago)
- Topics: asp-net-core, json-rpc, json-rpc-api, json-rpc-server, json-rpc2
- Language: C#
- Homepage:
- Size: 350 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Net JSON-RPC
Simple JSON-RPC protocol implementation based on ASP.NET Core project.
## Build
- `git clone https://github.com/giosil/NetJsonRpc.git`
- `dotnet publish NetJsonRpc/NetJsonRpc.csproj -c Release -o published`## Run
- `cd NetJsonRpc` - Starting dotnet in the root folder you get http 404 on launch index.html
- `dotnet published/NetJsonRpc.dll`## Run locally on Docker
- `docker build -t netjsonrpc .`
- `docker run --rm -it -p 5000:80 --name=netjsonrpc_test netjsonrpc`## Test
- `dotnet build`
- `dotnet test`## Example
```csharp
using System.Collections.Generic;using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;using NetJsonRpc.Protocol;
using NetJsonRpc.Services;namespace NetJsonRpc.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RpcController : ControllerBase
{
public RpcController(ILoggerFactory loggerFactory)
{
// Initialize RPC
RPC.AddHanlder("TEST", new TestService());
RPC.AddHanlder("DBMS", new DBService());
}
// GET api/rpc
[HttpGet]
public ActionResult Get()
{
return "JSON-RPC";
}
// POST api/rpc
[HttpPost]
public ActionResult> Post([FromBody] IDictionary request)
{
RPCRequest req = new RPCRequest(request);
RPCResponse res = RPC.Invoke(req);
return res.GetDictionary();
}
}
}
```## Contributors
* [Giorgio Silvestris](https://github.com/giosil)