coinprices/PriceEndpoints.hpp¶
Namespaces¶
| Name |
|---|
| sgns |
Functions¶
| Name | |
|---|---|
| std::string | GetPriceBaseUrl(const char * envName, const char * productionDefault) Resolve a price-tier base URL from the environment. |
| std::string | GetCoinGeckoBaseUrl() Tier 1 base URL: SGNS_COINGECKO_URL when set and non-empty, otherwise https://api.coingecko.com (LPM-09 CoinGecko defaults). |
| std::string | GetFallbackBaseUrl() Tier 2 base URL: SGNS_PRICE_FALLBACK_URL when set and non-empty, otherwise https://token.gnus.ai (LPM-09 defaults). |
Attributes¶
| Name | |
|---|---|
| constexpr const char * | kCoinGeckoBaseUrlDefault Production default base URL for tier 1 (CoinGecko direct). The client appends "/api/v3/simple/price". |
| constexpr const char * | kFallbackBaseUrlDefault Production default base URL for tier 2 (token.gnus.ai fallback). The client appends "/v1/prices". |
Functions Documentation¶
function GetPriceBaseUrl¶
Resolve a price-tier base URL from the environment.
Parameters:
- envName Environment variable name to read
- productionDefault Base URL used when the variable is unset or empty
Return: The env value when non-null AND non-empty, otherwise the production default
Note: The read is intentionally NOT cached in a function-local static: D-03 requires a fresh read at every LocalPriceManager construction so per-test stub-port redirection takes effect; a static would freeze the first value process-wide.
function GetCoinGeckoBaseUrl¶
Tier 1 base URL: SGNS_COINGECKO_URL when set and non-empty, otherwise https://api.coingecko.com (LPM-09 CoinGecko defaults).
Return: The resolved tier 1 base URL
function GetFallbackBaseUrl¶
Tier 2 base URL: SGNS_PRICE_FALLBACK_URL when set and non-empty, otherwise https://token.gnus.ai (LPM-09 defaults).
Return: The resolved tier 2 base URL
Attributes Documentation¶
variable kCoinGeckoBaseUrlDefault¶
Production default base URL for tier 1 (CoinGecko direct). The client appends "/api/v3/simple/price".
variable kFallbackBaseUrlDefault¶
Production default base URL for tier 2 (token.gnus.ai fallback). The client appends "/v1/prices".
Source code¶
#pragma once
#include <cstdlib>
#include <string>
namespace sgns
{
inline constexpr const char *kCoinGeckoBaseUrlDefault = "https://api.coingecko.com";
inline constexpr const char *kFallbackBaseUrlDefault = "https://token.gnus.ai";
inline std::string GetPriceBaseUrl( const char *envName, const char *productionDefault )
{
const char *env = std::getenv( envName );
if ( env != nullptr && *env != '\0' )
{
return std::string( env );
}
return std::string( productionDefault );
}
inline std::string GetCoinGeckoBaseUrl()
{
return GetPriceBaseUrl( "SGNS_COINGECKO_URL", kCoinGeckoBaseUrlDefault );
}
inline std::string GetFallbackBaseUrl()
{
return GetPriceBaseUrl( "SGNS_PRICE_FALLBACK_URL", kFallbackBaseUrlDefault );
}
} // namespace sgns
Updated on 2026-10-09 at 04:02:50 +0000