log directly to the terminal #170
@ -7,30 +7,30 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	createAccountPath = "/api/v2/account/create"
 | 
						createAccountPath          = "/api/v2/account/create"
 | 
				
			||||||
	trackStatusPath = "/api/track"
 | 
						trackStatusPath            = "/api/track"
 | 
				
			||||||
	balancePathPrefix = "/api/account"
 | 
						balancePathPrefix          = "/api/account"
 | 
				
			||||||
	trackPath = "/api/v2/account/status"
 | 
						trackPath                  = "/api/v2/account/status"
 | 
				
			||||||
	voucherHoldingsPathPrefix = "/api/v1/holdings"
 | 
						voucherHoldingsPathPrefix  = "/api/v1/holdings"
 | 
				
			||||||
	voucherTransfersPathPrefix = "/api/v1/transfers/last10"
 | 
						voucherTransfersPathPrefix = "/api/v1/transfers/last10"
 | 
				
			||||||
	voucherDataPathPrefix = "/api/v1/token"
 | 
						voucherDataPathPrefix      = "/api/v1/token"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	custodialURLBase string
 | 
						custodialURLBase     string
 | 
				
			||||||
	dataURLBase string
 | 
						dataURLBase          string
 | 
				
			||||||
	CustodialAPIKey string
 | 
						CustodialBearerToken string
 | 
				
			||||||
	DataAPIKey string
 | 
						DataBearerToken      string
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	CreateAccountURL string
 | 
						CreateAccountURL    string
 | 
				
			||||||
	TrackStatusURL   string
 | 
						TrackStatusURL      string
 | 
				
			||||||
	BalanceURL	string
 | 
						BalanceURL          string
 | 
				
			||||||
	TrackURL         string
 | 
						TrackURL            string
 | 
				
			||||||
	VoucherHoldingsURL	string
 | 
						VoucherHoldingsURL  string
 | 
				
			||||||
	VoucherTransfersURL	string
 | 
						VoucherTransfersURL string
 | 
				
			||||||
	VoucherDataURL	string
 | 
						VoucherDataURL      string
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func setBase() error {
 | 
					func setBase() error {
 | 
				
			||||||
@ -38,8 +38,8 @@ func setBase() error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	custodialURLBase = initializers.GetEnv("CUSTODIAL_URL_BASE", "http://localhost:5003")
 | 
						custodialURLBase = initializers.GetEnv("CUSTODIAL_URL_BASE", "http://localhost:5003")
 | 
				
			||||||
	dataURLBase = initializers.GetEnv("DATA_URL_BASE", "http://localhost:5006")
 | 
						dataURLBase = initializers.GetEnv("DATA_URL_BASE", "http://localhost:5006")
 | 
				
			||||||
	CustodialAPIKey = initializers.GetEnv("CUSTODIAL_API_KEY", "xd")
 | 
						CustodialBearerToken = initializers.GetEnv("CUSTODIAL_BEARER_TOKEN", "")
 | 
				
			||||||
	DataAPIKey = initializers.GetEnv("DATA_API_KEY", "xd")
 | 
						DataBearerToken = initializers.GetEnv("DATA_BEARER_TOKEN", "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, err = url.JoinPath(custodialURLBase, "/foo")
 | 
						_, err = url.JoinPath(custodialURLBase, "/foo")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@ -58,7 +58,7 @@ func LoadConfig() error {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	CreateAccountURL, _  = url.JoinPath(custodialURLBase, createAccountPath)
 | 
						CreateAccountURL, _ = url.JoinPath(custodialURLBase, createAccountPath)
 | 
				
			||||||
	TrackStatusURL, _ = url.JoinPath(custodialURLBase, trackStatusPath)
 | 
						TrackStatusURL, _ = url.JoinPath(custodialURLBase, trackStatusPath)
 | 
				
			||||||
	BalanceURL, _ = url.JoinPath(custodialURLBase, balancePathPrefix)
 | 
						BalanceURL, _ = url.JoinPath(custodialURLBase, balancePathPrefix)
 | 
				
			||||||
	TrackURL, _ = url.JoinPath(custodialURLBase, trackPath)
 | 
						TrackURL, _ = url.JoinPath(custodialURLBase, trackPath)
 | 
				
			||||||
 | 
				
			|||||||
@ -209,13 +209,13 @@ func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKRespons
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func doCustodialRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
 | 
					func doCustodialRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
 | 
				
			||||||
	req.Header.Set("X-GE-KEY", config.CustodialAPIKey)
 | 
						req.Header.Set("Authorization", "Bearer "+config.CustodialBearerToken)
 | 
				
			||||||
	logRequestDetails(req)
 | 
						logRequestDetails(req)
 | 
				
			||||||
	return doRequest(ctx, req, rcpt)
 | 
						return doRequest(ctx, req, rcpt)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func doDataRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
 | 
					func doDataRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
 | 
				
			||||||
	req.Header.Set("X-GE-KEY", config.DataAPIKey)
 | 
						req.Header.Set("Authorization", "Bearer "+config.DataBearerToken)
 | 
				
			||||||
	logRequestDetails(req)
 | 
						logRequestDetails(req)
 | 
				
			||||||
	return doRequest(ctx, req, rcpt)
 | 
						return doRequest(ctx, req, rcpt)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user