Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Stdio server

# stdio_server.nim

{.push gcsafe, raises: [].}

import json_rpc/servers/stdioserver
import ./rpc_format

export stdioserver

proc setupServer(srv: RpcStdioServer) =
  srv.rpc(RpcConv):
    proc hello(input: string): string =
      "Hello " & input

proc main() {.raises: [CancelledError, JsonRpcError].} =
  let srv = newRpcStdioServer(framing = Framing.httpHeader())

  srv.setupServer()

  waitFor srv.serve()

when isMainModule:
  main()