mirror of
https://github.com/luxfi/coreth.git
synced 2026-10-30 17:00:51 +00:00
- Update import from vm/rpcchainvm to vm/rpc/chain - Update vm dependency to v1.0.18 - node dependency now test-only (platformvm.NewClient for warp tests)
22 lines
764 B
Go
22 lines
764 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"
|
|
json "github.com/luxfi/codec/jsonrpc"
|
|
)
|
|
|
|
// 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)
|
|
}
|