internal

package
v0.0.0-...-c4ef61d Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvanceTradeAPIEndpoint

type AdvanceTradeAPIEndpoint struct {
	Production *Endpoint
	Sandbox    *Endpoint
}

type AuthTransport

type AuthTransport struct {
	Base http.RoundTripper
	JWT  string
}

AuthTransport is a transport that adds an Authorization header to the request.

func (*AuthTransport) RoundTrip

func (a *AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Endpoint

type Endpoint struct {
	RESTBaseURL  string
	WebSocketURL string
}

type Options

type Options struct {
	AdvanceTradeAPIEndpoint *AdvanceTradeAPIEndpoint
	Logger                  *slog.Logger
	JWT                     string // it's almost useless to set JWT at this level, but keeping this for backward compatibility
}

func (Options) NewHTTPClient

func (o Options) NewHTTPClient() (*http.Client, error)

func (Options) NewTransport

func (o Options) NewTransport() (http.RoundTripper, error)

type RESTClient

type RESTClient struct {
	HttpClient              *http.Client
	Logger                  *slog.Logger
	AdvanceTradeAPIEndpoint *AdvanceTradeAPIEndpoint
}

RESTClient represents a client for making HTTP requests.

func (*RESTClient) DoRequest

func (c *RESTClient) DoRequest(ctx context.Context, method, url string, query urlpkg.Values, result, reqBody interface{}) error

DoRequest sends an HTTP request and processes the response. it is pretty dumb in the sense, it doesn't automatically verify the url endpoints e.g. websocket or REST

type WebSocketClient

type WebSocketClient struct {
	Connection              *websocket.Conn
	Logger                  *slog.Logger
	AdvanceTradeAPIEndpoint *AdvanceTradeAPIEndpoint
}

WebSocketClient represents a client for making HTTP requests.

func (*WebSocketClient) SetConnection

func (w *WebSocketClient) SetConnection(baseUrl string) error

Jump to

Keyboard shortcuts

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