src/TAO/API/types/names/initialize.cpp
std::string Names::RewriteURL(const std::string& strMethod, json::json& jsonParams)
        {
            /* The rewritten method name to return.  Default to the method name passed in */
            std::string strMethodRewritten = strMethod;

            /* support passing the name after the method e.g. get/name/myname */
            std::string strNameOrAddress;

            /* First check for /name/ */
            std::size_t nPos = strMethod.find("/name/");
            if(nPos != std::string::npos)
            {
                /* Edge case for /names/list/name/history/somename */
                if(strMethod == "list/name/history")
                    return strMethod;
                else if(strMethod.find("list/name/history/") != std::string::npos)
                {
                    strMethodRewritten = "list/name/history";

                    /* Get the name or address that comes after the list/name/history part */
                    strNameOrAddress = strMethod.substr(18); 
                }
                else
                {
                    /* get the method name from the incoming string */
                    strMethodRewritten = strMethod.substr(0, nPos+5);

                    /* Get the name or address that comes after the /name/ part */
                    strNameOrAddress = strMethod.substr(nPos +6);
                }
            }

            /* Next check for /namespace/ */
            nPos = strMethod.find("/namespace/");
            if(nPos != std::string::npos)
            {
                /* Edge case for /names/list/namespace/history/somename */
                if(strMethod == "list/namespace/history")
                    return strMethod;
                else if(strMethod.find("list/namespace/history/") != std::string::npos)
                {
                    strMethodRewritten = "list/namespace/history";

                    /* Get the name or address that comes after the list/name/history part */
                    strNameOrAddress = strMethod.substr(23); 
                }
                else
                {
                    /* get the method name from the incoming string */
                    strMethodRewritten = strMethod.substr(0, nPos+10);

                    /* Get the name or address that comes after the /namespace/ part */
                    strNameOrAddress = strMethod.substr(nPos +11);
                }
            }


            if(!strNameOrAddress.empty())
            {
                /* Edge case for claim/name/txid */
                if(strMethodRewritten == "claim/name" || strMethodRewritten == "claim/namespace")
                    jsonParams["txid"] = strNameOrAddress;
                /* Determine whether the name/address is a valid register address and set the name or address parameter accordingly */
                else if(IsRegisterAddress(strNameOrAddress) && strMethodRewritten == "get/name")
                    jsonParams["register_address"] = strNameOrAddress;
                else if(IsRegisterAddress(strNameOrAddress))
                    jsonParams["address"] = strNameOrAddress;
                else
                    jsonParams["name"] = strNameOrAddress;
            }       

            return strMethodRewritten;
        }
/* Allows derived API's to handle custom/dynamic URL's where the strMethod does not
         *  map directly to a function in the target API.  Insted this method can be overriden to
         *  parse the incoming URL and route to a different/generic method handler, adding parameter
         *  values if necessary.  E.g. get/myasset could be rerouted to get/asset with name=myasset
         *  added to the jsonParams
         *  The return json contains the modifed method URL to be called.
         */
Allows derived API's to handle custom/dynamic URL's where the strMethod does not
map directly to a function in the target API.  Insted this method can be overriden to
parse the incoming URL and route to a different/generic method handler, adding parameter
values if necessary.
Allows derived API ' s to handle custom / dynamic URL ' s where the strMethod does not map directly to a function in the target API . Insted this method can be overriden to parse the incoming URL and route to a different / generic method handler adding parameter values if necessary .
std::string Names::RewriteURL(const std::string& strMethod, json::json& jsonParams)
        {
            std::string strMethodRewritten = strMethod;
            std::string strNameOrAddress;
            std::size_t nPos = strMethod.find("/name/");
            if(nPos != std::string::npos)
            {
                if(strMethod == "list/name/history")
                    return strMethod;
                else if(strMethod.find("list/name/history/") != std::string::npos)
                {
                    strMethodRewritten = "list/name/history";
                    strNameOrAddress = strMethod.substr(18); 
                }
                else
                {
                    strMethodRewritten = strMethod.substr(0, nPos+5);
                    strNameOrAddress = strMethod.substr(nPos +6);
                }
            }
            nPos = strMethod.find("/namespace/");
            if(nPos != std::string::npos)
            {
                if(strMethod == "list/namespace/history")
                    return strMethod;
                else if(strMethod.find("list/namespace/history/") != std::string::npos)
                {
                    strMethodRewritten = "list/namespace/history";
                    strNameOrAddress = strMethod.substr(23); 
                }
                else
                {
                    strMethodRewritten = strMethod.substr(0, nPos+10);
                    strNameOrAddress = strMethod.substr(nPos +11);
                }
            }
            if(!strNameOrAddress.empty())
            {
                if(strMethodRewritten == "claim/name" || strMethodRewritten == "claim/namespace")
                    jsonParams["txid"] = strNameOrAddress;
                else if(IsRegisterAddress(strNameOrAddress) && strMethodRewritten == "get/name")
                    jsonParams["register_address"] = strNameOrAddress;
                else if(IsRegisterAddress(strNameOrAddress))
                    jsonParams["address"] = strNameOrAddress;
                else
                    jsonParams["name"] = strNameOrAddress;
            }       
            return strMethodRewritten;
        }
std :: string Names :: RewriteURL ( const std :: string & strMethod , json :: json & jsonParams ) { std :: string strMethodRewritten = strMethod ; std :: string strNameOrAddress ; std :: size_t nPos = strMethod . find ( " " ) ; if ( nPos != std :: string :: npos ) { if ( strMethod == " " ) return strMethod ; else if ( strMethod . find ( " " ) != std :: string :: npos ) { strMethodRewritten = " " ; strNameOrAddress = strMethod . substr ( 18 ) ; } else { strMethodRewritten = strMethod . substr ( 0 , nPos + 5 ) ; strNameOrAddress = strMethod . substr ( nPos + 6 ) ; } } nPos = strMethod . find ( " " ) ; if ( nPos != std :: string :: npos ) { if ( strMethod == " " ) return strMethod ; else if ( strMethod . find ( " " ) != std :: string :: npos ) { strMethodRewritten = " " ; strNameOrAddress = strMethod . substr ( 23 ) ; } else { strMethodRewritten = strMethod . substr ( 0 , nPos + 10 ) ; strNameOrAddress = strMethod . substr ( nPos + 11 ) ; } } if ( ! strNameOrAddress . empty ( ) ) { if ( strMethodRewritten == " " || strMethodRewritten == " " ) jsonParams [ " " ] = strNameOrAddress ; else if ( IsRegisterAddress ( strNameOrAddress ) && strMethodRewritten == " " ) jsonParams [ " " ] = strNameOrAddress ; else if ( IsRegisterAddress ( strNameOrAddress ) ) jsonParams [ " " ] = strNameOrAddress ; else jsonParams [ " " ] = strNameOrAddress ; } return strMethodRewritten ; }
Allows derived API's to handle custom/dynamic URL's where the strMethod does not
  map directly to a function in the target API.
Allows derived API ' s to handle custom / dynamic URL ' s where the strMethod does not map directly to a function in the target API .
/* The rewritten method name to return.  Default to the method name passed in */ /* support passing the name after the method e.g. get/name/myname */ /* First check for /name/ */ /* Edge case for /names/list/name/history/somename */ /* Get the name or address that comes after the list/name/history part */ /* get the method name from the incoming string */ /* Get the name or address that comes after the /name/ part */ /* Next check for /namespace/ */ /* Edge case for /names/list/namespace/history/somename */ /* Get the name or address that comes after the list/name/history part */ /* get the method name from the incoming string */ /* Get the name or address that comes after the /namespace/ part */ /* Edge case for claim/name/txid */ /* Determine whether the name/address is a valid register address and set the name or address parameter accordingly */