mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Support API versioning
This commit is contained in:
@@ -716,5 +716,24 @@ beast::SemanticVersion const firstVersion("1.0.0");
|
||||
beast::SemanticVersion const goodVersion("1.0.0");
|
||||
beast::SemanticVersion const lastVersion("1.0.0");
|
||||
|
||||
unsigned int getAPIVersionNumber(Json::Value const& jv)
|
||||
{
|
||||
static Json::Value const minVersion (RPC::ApiMinimumSupportedVersion);
|
||||
static Json::Value const maxVersion (RPC::ApiMaximumSupportedVersion);
|
||||
static Json::Value const invalidVersion (RPC::APIInvalidVersion);
|
||||
|
||||
Json::Value requestedVersion(RPC::APIVersionIfUnspecified);
|
||||
if(jv.isObject())
|
||||
{
|
||||
requestedVersion = jv.get (jss::api_version, requestedVersion);
|
||||
}
|
||||
if( !(requestedVersion.isInt() || requestedVersion.isUInt()) ||
|
||||
requestedVersion < minVersion || requestedVersion > maxVersion)
|
||||
{
|
||||
requestedVersion = invalidVersion;
|
||||
}
|
||||
return requestedVersion.asUInt();
|
||||
}
|
||||
|
||||
} // RPC
|
||||
} // ripple
|
||||
|
||||
Reference in New Issue
Block a user