1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/plugins/codec/jsonrpc2
Asim Aslam 62801c3d68 update
2021-10-13 13:31:23 +01:00
..
client.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
errors.go add all the plugins 2020-12-26 15:32:45 +00:00
go.mod update 2021-10-13 13:31:23 +01:00
go.sum update 2021-10-13 13:31:23 +01:00
jsonrpc2.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
license.go add all the plugins 2020-12-26 15:32:45 +00:00
README.md go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
server.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00

JSON-RPC 2.0 Codec

Usage

Import the codec and set within the client/server

package main

import (
    "go-micro.dev/v4"
    "github.com/micro/go-micro/client"
    "github.com/micro/go-micro/server"
    "github.com/asim/go-micro/plugins/codec/jsonrpc2"
)

func main() {
    client := client.NewClient(
        client.Codec("application/json", jsonrpc2.NewCodec),
        client.ContentType("application/json"),
    )

    server := server.NewServer(
        server.Codec("application/json", jsonrpc2.NewCodec),
    )

    service := micro.NewService(
        micro.Client(client),
        micro.Server(server),
    )

    // ...
}