mirror of
https://github.com/luxfi/rpc.git
synced 2026-10-30 15:19:52 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
48 lines
799 B
Go
48 lines
799 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package rpc
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
)
|
|
|
|
var _ EndpointRequester = (*luxEndpointRequester)(nil)
|
|
|
|
type EndpointRequester interface {
|
|
SendRequest(ctx context.Context, method string, params any, reply any, options ...Option) error
|
|
}
|
|
|
|
type luxEndpointRequester struct {
|
|
uri string
|
|
}
|
|
|
|
func NewEndpointRequester(uri string) EndpointRequester {
|
|
return &luxEndpointRequester{
|
|
uri: uri,
|
|
}
|
|
}
|
|
|
|
func (e *luxEndpointRequester) SendRequest(
|
|
ctx context.Context,
|
|
method string,
|
|
params any,
|
|
reply any,
|
|
options ...Option,
|
|
) error {
|
|
uri, err := url.Parse(e.uri)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return SendJSONRequest(
|
|
ctx,
|
|
uri,
|
|
method,
|
|
params,
|
|
reply,
|
|
options...,
|
|
)
|
|
}
|