README.md

# pollux

Work with JSON RPC (jsonrpc 2.0)

[![Package Version](https://img.shields.io/hexpm/v/pollux)](https://hex.pm/packages/pollux)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/pollux/)

```sh
gleam add pollux@1
```

## Usage

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

```gleam
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

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

## Credit

Created for [EYG](https://eyg.run/), a new integration focused programming language.