mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
- Copied api and utils/rpc packages from node to remove dependency - Updated imports to use local packages - Removed node from go.mod requirements - Core EVM package now builds without node dependency - Only runner/main (for testing) still uses node/vms/rpcchainvm This allows EVM to be used as a library without pulling in the entire node package tree.
52 lines
895 B
Go
52 lines
895 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package rpc // Copied from luxfi/node to remove dependency
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
type Option func(*Options)
|
|
|
|
type Options struct {
|
|
headers http.Header
|
|
queryParams url.Values
|
|
}
|
|
|
|
func NewOptions(ops []Option) *Options {
|
|
o := &Options{
|
|
headers: http.Header{},
|
|
queryParams: url.Values{},
|
|
}
|
|
o.applyOptions(ops)
|
|
return o
|
|
}
|
|
|
|
func (o *Options) applyOptions(ops []Option) {
|
|
for _, op := range ops {
|
|
op(o)
|
|
}
|
|
}
|
|
|
|
func (o *Options) Headers() http.Header {
|
|
return o.headers
|
|
}
|
|
|
|
func (o *Options) QueryParams() url.Values {
|
|
return o.queryParams
|
|
}
|
|
|
|
func WithHeader(key, val string) Option {
|
|
return func(o *Options) {
|
|
o.headers.Set(key, val)
|
|
}
|
|
}
|
|
|
|
func WithQueryParam(key, val string) Option {
|
|
return func(o *Options) {
|
|
o.queryParams.Set(key, val)
|
|
}
|
|
}
|