{"size": 1413, "ext": "scrbl", "max_stars_repo_path": "scribblings/jsonrpc.scrbl", "max_stars_repo_name": "dannypsnl-fork/jsonrpc", "max_stars_repo_stars_event_min_datetime": "2021-06-11T05:10:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-08T14:30:00.000Z", "max_issues_repo_path": "scribblings/jsonrpc.scrbl", "max_issues_repo_name": "dannypsnl-fork/jsonrpc", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scribblings/jsonrpc.scrbl", "max_forks_repo_name": "dannypsnl-fork/jsonrpc", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.8367346939, "max_line_length": 91, "alphanum_fraction": 0.500353857}
#lang scribble/manual

@require[@for-label[jsonrpc
                    racket/base
                    json]]

@title{jsonrpc}
@author{Lîm Tsú-thuàn}

@defmodule[jsonrpc]

@section{client}

@defform[(jsonrpc-send! url jsexpr)
         #:contracts [(url string?)
                      (jsexpr jsexpr?)]]{
 Example

 @(racketblock
   (jsonrpc-send!
    "http://localhost:4389/jsonrpc"
    (hasheq 'jsonrpc "2.0"
            'id "0"
            'method "initialize"
            'params (hasheq 'processId 0
                            'rootUri "file://Users/linzizhuan/dannypsnl/jsonrpc"
                            'capabilities (hasheq 'hoverProvider #t
                                                  'definitionProvider #t
                                                  'documentSymbolProvider #t
                                                  'documentLinkProvider #t
                                                  'documentFormattingProvider #t
                                                  'documentRangeFormattingProvider #t)))))}

@section{server}

@defform[(jsonrpc-start user-handler)
         #:contracts [(user-handler (-> integer? string? jsexpr? void?))]]{
 Example

 @(racketblock
   (define (user-handler id method params)
     (success-response id params))

   (serve/servlet
    (jsonrpc-start user-handler)
    #:port 4389
    #:launch-browser? #f
    #:servlet-path "/jsonrpc"))}
