pollux

Work with JSON RPC (jsonrpc 2.0)

Package Version Hex Docs

gleam add pollux@1

Usage

Pollux requires you to define your own application types for Request/Notification and response

import pollux

/// App specific notifications
pub type MyNotification{
  MyNotification
}

  /// App specific request
pub type MyRequest {
  MyRequest
}

pub type MyResponse {
  MyResponse
}

fn request_decoder(){
  pollux.request_decoder(my_request_decoder, my_notification_decoder, ZeroNotification)
}

pub fn server()  {
  case json.parse(input, my_decoder()) {
    pollux.Request(id:, ..) -> {
      pollux.response(id, Ok(MyResponse))
      |> pollux.response_encode(my_response_encode)
    }
    pollux.Notification(..) -> todo
  }
}

Further documentation can be found at https://hexdocs.pm/pollux.

Development

gleam run   # Run the project
gleam test  # Run the tests

Credit

Created for EYG, a new integration focused programming language.

Search Document