go-rpc-provider-proxy

module
v0.0.0-...-318b7a7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2021 License: MIT

README

go-rpc-provider-proxy

A simple Go HTTP server that proxies RPC provider requests.

Getting started

# terminal 1
$ go run cmd/proxy/main.go -proxy-url="https://kovan.infura.io/v3/84842078b09946638c03157f83405213" -proxy-method=POST -port=8000
Proxying POST https://kovan.infura.io/v3/84842078b09946638c03157f83405213
Listening on port 8000

# terminal 2
$ curl http://localhost:8000 -X POST -H "content-type: application/json" -d '{"method":"eth_getCode","params":["0xf2b139bd79e08f9273e6a3dc2702051e1b16cdf8","latest"],"id":13009,"jsonrpc":"2.0"}'

Authorization header example:

# terminal 1
$ go run cmd/proxy/main.go -proxy-url="https://kovan.infura.io/v3/84842078b09946638c03157f83405213" -proxy-method=POST -port=8000 -auth-secret=mysecret

# terminal 2
$ echo -n mysecret | openssl base64
bXlzZWNyZXQ=

$ curl http://localhost:8000 -X POST -H "content-type: application/json" -H "Authorization: Bearer bXlzZWNyZXQ=" -d '{"method":"eth_getCode","params":["0xf2b139bd79e08f9273e6a3dc2702051e1b16cdf8","latest"],"id":13009,"jsonrpc":"2.0"}'

Test

Run load testing script:

make loadtest

Development

Build and push docker image to registry:

make docker-build-and-push

License

MIT

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL