generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed names, comments, broke files apart, upgraded deps, etc
- Loading branch information
Showing
14 changed files
with
298 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package transports | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/libsv/go-bk/bec" | ||
"github.com/libsv/go-bk/bip32" | ||
) | ||
|
||
// WithXPriv will set the xPriv | ||
func WithXPriv(xPriv *bip32.ExtendedKey) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.xPriv = xPriv | ||
} | ||
} | ||
} | ||
|
||
// WithXPub will set the xPub | ||
func WithXPub(xPub *bip32.ExtendedKey) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.xPub = xPub | ||
} | ||
} | ||
} | ||
|
||
// WithAccessKey will set the access key | ||
func WithAccessKey(accessKey *bec.PrivateKey) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.accessKey = accessKey | ||
} | ||
} | ||
} | ||
|
||
// WithGraphQL will overwrite the default client with a custom client | ||
func WithGraphQL(serverURL string) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.transport = NewTransportService(&TransportGraphQL{ | ||
debug: c.debug, | ||
server: serverURL, | ||
signRequest: c.signRequest, | ||
adminXPriv: c.adminXPriv, | ||
httpClient: &http.Client{}, | ||
xPriv: c.xPriv, | ||
xPub: c.xPub, | ||
accessKey: c.accessKey, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
// WithHTTP will overwrite the default client with a custom client | ||
func WithHTTP(serverURL string) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.transport = NewTransportService(&TransportHTTP{ | ||
debug: c.debug, | ||
server: serverURL, | ||
signRequest: c.signRequest, | ||
adminXPriv: c.adminXPriv, | ||
httpClient: &http.Client{}, | ||
xPriv: c.xPriv, | ||
xPub: c.xPub, | ||
accessKey: c.accessKey, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
// WithGraphQLClient will overwrite the default client with a custom client | ||
func WithGraphQLClient(serverURL string, httpClient *http.Client) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.transport = NewTransportService(&TransportGraphQL{ | ||
debug: c.debug, | ||
server: serverURL, | ||
signRequest: c.signRequest, | ||
adminXPriv: c.adminXPriv, | ||
httpClient: httpClient, | ||
xPriv: c.xPriv, | ||
xPub: c.xPub, | ||
accessKey: c.accessKey, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
// WithHTTPClient will overwrite the default client with a custom client | ||
func WithHTTPClient(serverURL string, httpClient *http.Client) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.transport = NewTransportService(&TransportHTTP{ | ||
debug: c.debug, | ||
server: serverURL, | ||
signRequest: c.signRequest, | ||
adminXPriv: c.adminXPriv, | ||
httpClient: httpClient, | ||
xPriv: c.xPriv, | ||
xPub: c.xPub, | ||
accessKey: c.accessKey, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
// WithAdminKey will set the admin key for admin requests | ||
func WithAdminKey(adminKey string) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.adminKey = adminKey | ||
} | ||
} | ||
} | ||
|
||
// WithSignRequest will set whether to sign all requests | ||
func WithSignRequest(signRequest bool) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.signRequest = signRequest | ||
if c.transport != nil { | ||
c.transport.SetSignRequest(signRequest) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// WithDebugging will set whether to turn debugging on | ||
func WithDebugging(debug bool) ClientOps { | ||
return func(c *Client) { | ||
if c != nil { | ||
c.debug = debug | ||
if c.transport != nil { | ||
c.transport.SetDebug(debug) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.