Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub action v4 #199

Merged
merged 4 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
continue-on-error: ${{ matrix.branch == 'devel' }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install build dependencies (Linux i386)
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
- name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows'
id: windows-dlls-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: external/dlls-${{ matrix.target.cpu }}
key: 'dlls-${{ matrix.target.cpu }}'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg)
![Github action](https://github.com/status-im/nim-json-rpc/workflows/CI/badge.svg)
![Github action](https://github.com/status-im/nim-json-rpc/actions/workflows/ci.yml/badge.svg)

Json-Rpc is a library designed to provide an easier interface for working with remote procedure calls.

Expand Down
12 changes: 6 additions & 6 deletions json_rpc/router.nim
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ proc route*(router: RpcRouter, data: string):
## converted to Json.
## Returns string of Json from RPC result/error node
when defined(nimHasWarnBareExcept):
{.warning[BareExcept]:off.}
{.push warning[BareExcept]:off.}

let request =
try:
Expand All @@ -172,7 +172,7 @@ proc route*(router: RpcRouter, data: string):
return wrapError(JSON_ENCODE_ERROR, err.msg)

when defined(nimHasWarnBareExcept):
{.warning[BareExcept]:on.}
{.pop warning[BareExcept]:on.}

return reply

Expand All @@ -181,8 +181,8 @@ proc tryRoute*(router: RpcRouter, data: JsonString,
## Route to RPC, returns false if the method or params cannot be found.
## Expects json input and returns json output.
when defined(nimHasWarnBareExcept):
{.warning[BareExcept]:off.}
{.warning[UnreachableCode]:off.}
{.push warning[BareExcept]:off.}
{.push warning[UnreachableCode]:off.}

try:
let req = JrpcSys.decode(data.string, RequestRx)
Expand All @@ -206,8 +206,8 @@ proc tryRoute*(router: RpcRouter, data: JsonString,
return err(ex.msg)

when defined(nimHasWarnBareExcept):
{.warning[BareExcept]:on.}
{.warning[UnreachableCode]:on.}
{.pop warning[BareExcept]:on.}
{.pop warning[UnreachableCode]:on.}

macro rpc*(server: RpcRouter, path: static[string], body: untyped): untyped =
## Define a remote procedure call.
Expand Down
16 changes: 2 additions & 14 deletions json_rpc/servers/httpserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,7 @@ proc serveHTTP*(rpcServer: RpcHttpHandler, request: HttpRequestRef):
raise exc
except CatchableError as exc:
debug "Internal error while processing JSON-RPC call"
try:
return await request.respond(
Http503,
"Internal error while processing JSON-RPC call: " & exc.msg)
except HttpWriteError as exc:
error "Something error", msg=exc.msg
return defaultResponse()
return defaultResponse(exc)

proc processClientRpc(rpcServer: RpcHttpServer): HttpProcessCallback2 =
return proc (req: RequestFence): Future[HttpResponseRef]
Expand All @@ -104,13 +98,7 @@ proc processClientRpc(rpcServer: RpcHttpServer): HttpProcessCallback2 =
return res
except CatchableError as exc:
error "Internal error while processing JSON-RPC hook", msg=exc.msg
try:
return await request.respond(
Http503,
"Internal error while processing JSON-RPC hook: " & exc.msg)
except HttpWriteError as exc:
error "Something error", msg=exc.msg
return defaultResponse()
return defaultResponse(exc)

return await rpcServer.serveHTTP(request)

Expand Down