Files
coreth/utils/rpc/handler.go
zeekay 2b09067132 codec rip: switch wrappers + jsonrpc consumers to luxfi/utils
- sync/statesync (test_trie + trie_segments): codec/wrappers ->
  luxfi/utils/wrappers (canonical Packer + ByteLen/ShortLen/LongLen).
- utils/rpc/handler.go: codec/jsonrpc -> luxfi/utils/json (NewCodec).
- plugin/evm/atomic/vm/api.go + plugin/evm/client/client.go:
  codec/jsonrpc -> luxfi/utils/json for Uint32/Uint64 quoted JSON.

All three subpackages have identical API in luxfi/utils v1.1.5; coreth
no longer imports codec/wrappers or codec/jsonrpc — coreth still
imports codec/linearcodec from plugin/evm/secpfx, which is the SECP fx
that needs the legacy codec.Registry binding to plug into the C-chain
fx system. Documented as structural retain.
2026-06-06 02:56:52 -07:00

22 lines
756 B
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package rpc
import (
"net/http"
"github.com/gorilla/rpc/v2"
"github.com/luxfi/utils/json"
)
// NewHandler returns a new Handler for a service where:
// - The handler's functionality is defined by [service]
// [service] should be a gorilla RPC service (see https://www.gorillatoolkit.org/pkg/rpc/v2)
// - The name of the service is [name]
func NewHandler(name string, service interface{}) (http.Handler, error) {
server := rpc.NewServer()
server.RegisterCodec(json.NewCodec(), "application/json")
server.RegisterCodec(json.NewCodec(), "application/json;charset=UTF-8")
return server, server.RegisterService(service, name)
}