Skip to content

Conversation

@praetoriansentry
Copy link
Member

@praetoriansentry praetoriansentry commented Jan 9, 2024

Description

Adding a flag to add an authorization bearer to http requests.

Tests

Ensure polycli monitor is working:

./out/polycli monitor -H "X-goog-api-key: $apikey" --rpc-url https://json-rpc.do9ic5iuox53t826lv7lqek2p.blockchainnodeengine.com

Ensure loadtest command works with the custom header as well:

./out/polycli loadtest --mode rpc -H "X-goog-api-key: $apikey" --rpc-url https://json-rpc.do9ic5iuox53t826lv7lqek2p.blockchainnodeengine.com --verbosity 700 --requests 100 --concurrency 10 --rate-limit 50

ltp.ContractCallFunctionArgs = LoadtestCmd.Flags().StringSlice("function-arg", []string{}, `The arguments that will be passed to a contract function call. This must be paired up with "--mode contract-call" and "--contract-address". Args can be passed multiple times: "--function-arg 'test' --function-arg 999" or comma separated values "--function-arg "test",9". The ordering of the arguments must match the ordering of the function parameters.`)
ltp.ContractCallPayable = LoadtestCmd.Flags().Bool("contract-call-payable", false, "Use this flag if the function is payable, the value amount passed will be from --eth-amount. This must be paired up with --mode contract-call and --contract-address")
ltp.InscriptionContent = LoadtestCmd.Flags().String("inscription-content", `data:,{"p":"erc-20","op":"mint","tick":"TEST","amt":"1"}`, "The inscription content that will be encoded as calldata. This must be paired up with --mode inscription")
ltp.RawHTTPHeaders = LoadtestCmd.Flags().StringSliceP("header", "H", nil, "Header to be added to each HTTP request. E.g. \"X-First-Name: Joe\"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for clarity: if user needs to pass multiple headers, what is the recommended / valid format? pass multiple -H flags to polycli cmd, or, single -H with comma separated set of headers?

var rpc *ethrpc.Client
var err error
if inputLoadTestParams.ParsedHTTPHeaders == nil {
log.Trace().Msg("No HeadersAdding custom headers")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, spacing: No Headers. Adding custom headers.

```bash
-b, --batch-size string Number of requests per batch (default "auto")
-c, --cache-limit int Number of cached blocks for the LRU block data structure (Min 100) (default 200)
-H, --header strings Header to be added to each HTTP request. E.g. "X-First-Name: Joe"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in same vein, consider adding bit extra clarity for users needing to pass multiple headers

@minhd-vu minhd-vu changed the title Adding support for authorization header feat: add support for authorization header Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants