Add config
This commit is contained in:
parent
3ea726a030
commit
c877bccff6
73
config/config.go
Normal file
73
config/config.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"git.grassecon.net/grassrootseconomics/common/env"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
createAccountPath = "/api/v2/account/create"
|
||||||
|
trackStatusPath = "/api/track"
|
||||||
|
balancePathPrefix = "/api/account"
|
||||||
|
trackPath = "/api/v2/account/status"
|
||||||
|
tokenTransferPrefix = "/api/v2/token/transfer"
|
||||||
|
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
||||||
|
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
||||||
|
voucherDataPathPrefix = "/api/v1/token"
|
||||||
|
AliasPrefix = "api/v1/alias"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
custodialURLBase string
|
||||||
|
dataURLBase string
|
||||||
|
BearerToken string
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
CreateAccountURL string
|
||||||
|
TrackStatusURL string
|
||||||
|
BalanceURL string
|
||||||
|
TrackURL string
|
||||||
|
TokenTransferURL string
|
||||||
|
VoucherHoldingsURL string
|
||||||
|
VoucherTransfersURL string
|
||||||
|
VoucherDataURL string
|
||||||
|
CheckAliasURL string
|
||||||
|
)
|
||||||
|
|
||||||
|
func setBase() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
custodialURLBase = env.GetEnv("CUSTODIAL_URL_BASE", "http://localhost:5003")
|
||||||
|
dataURLBase = env.GetEnv("DATA_URL_BASE", "http://localhost:5006")
|
||||||
|
BearerToken = env.GetEnv("BEARER_TOKEN", "")
|
||||||
|
|
||||||
|
_, err = url.Parse(custodialURLBase)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = url.Parse(dataURLBase)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadConfig() error {
|
||||||
|
err := setBase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
CreateAccountURL, _ = url.JoinPath(custodialURLBase, createAccountPath)
|
||||||
|
TrackStatusURL, _ = url.JoinPath(custodialURLBase, trackStatusPath)
|
||||||
|
BalanceURL, _ = url.JoinPath(custodialURLBase, balancePathPrefix)
|
||||||
|
TrackURL, _ = url.JoinPath(custodialURLBase, trackPath)
|
||||||
|
TokenTransferURL, _ = url.JoinPath(custodialURLBase, tokenTransferPrefix)
|
||||||
|
VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix)
|
||||||
|
VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix)
|
||||||
|
VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix)
|
||||||
|
CheckAliasURL, _ = url.JoinPath(dataURLBase, AliasPrefix)
|
||||||
|
return nil
|
||||||
|
}
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.grassecon.net/grassrootseconomics/sarafu-api
|
|||||||
go 1.23.4
|
go 1.23.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250112094202-96345daf4d75
|
||||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta
|
github.com/grassrootseconomics/eth-custodial v1.3.0-beta
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
|
4
go.sum
4
go.sum
@ -1,5 +1,5 @@
|
|||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa h1:owrXxiDOp7uuyvGxi4DU8gu8PyA7YxVnX8bo7i28Anw=
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250112094202-96345daf4d75 h1:g/dZdu1teBggAMFCwm7BpV44bz394+nhAduULjX6Kk4=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U=
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250112094202-96345daf4d75/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta h1:twrMBhl89GqDUL9PlkzQxMP/6OST1BByrNDj+rqXDmU=
|
github.com/grassrootseconomics/eth-custodial v1.3.0-beta h1:twrMBhl89GqDUL9PlkzQxMP/6OST1BByrNDj+rqXDmU=
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||||
"github.com/grassrootseconomics/eth-custodial/pkg/api"
|
"github.com/grassrootseconomics/eth-custodial/pkg/api"
|
||||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||||
|
Loading…
Reference in New Issue
Block a user