mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
6672d1499a
* wip proposer settings * WIP validator client APIs * adding proposer settings output * adding unit tests * fixing linting * fixing deepsource issues * fixing e2e * fixing deep source issue * updating naming to not stutter * updating bazel * fixing linting error * reverting comment * adding builder settings * gaz * Update validator/client/validator.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * adding comments * adding some tests * gaz * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/errors.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/validator/client.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/cmd.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/validator/client.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/validator/client.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/errors.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * fixing feedback * fixing unit test * addressign comments --------- Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package client
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// ReqOption is a request functional option.
|
|
type ReqOption func(*http.Request)
|
|
|
|
// WithSSZEncoding is a request functional option that adds SSZ encoding header.
|
|
func WithSSZEncoding() ReqOption {
|
|
return func(req *http.Request) {
|
|
req.Header.Set("Accept", "application/octet-stream")
|
|
}
|
|
}
|
|
|
|
// WithAuthorizationToken is a request functional option that adds header for authorization token.
|
|
func WithAuthorizationToken(token string) ReqOption {
|
|
return func(req *http.Request) {
|
|
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
|
}
|
|
}
|
|
|
|
// ClientOpt is a functional option for the Client type (http.Client wrapper)
|
|
type ClientOpt func(*Client)
|
|
|
|
// WithTimeout sets the .Timeout attribute of the wrapped http.Client.
|
|
func WithTimeout(timeout time.Duration) ClientOpt {
|
|
return func(c *Client) {
|
|
c.hc.Timeout = timeout
|
|
}
|
|
}
|
|
|
|
// WithRoundTripper replaces the underlying HTTP's transport with a custom one.
|
|
func WithRoundTripper(t http.RoundTripper) ClientOpt {
|
|
return func(c *Client) {
|
|
c.hc.Transport = t
|
|
}
|
|
}
|
|
|
|
// WithAuthenticationToken sets an oauth token to be used.
|
|
func WithAuthenticationToken(token string) ClientOpt {
|
|
return func(c *Client) {
|
|
c.token = token
|
|
}
|
|
}
|