1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-17 17:44:30 +02:00
2021-11-11 14:03:34 +00:00
..
2021-10-12 12:55:53 +01:00
2020-12-26 15:32:45 +00:00
2021-11-11 14:03:34 +00:00
2021-11-11 14:03:34 +00:00
2021-10-12 12:55:53 +01:00
2020-12-26 15:32:45 +00:00
2021-10-12 12:55:53 +01:00
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),
    )

    // ...
}