oracle-apexoracle-ords

Get path param value into ORDS prehook


Is there a way to get pathparam from url with get_cgi_env? Example: https://clientes/{codigo}. I would like to get the value from :codigo pathparam.

Into handler GET, POST, PUT, etc. on endpoint it is possible to get the pathparam value but it's not clear how can to be done into ORDS prehook.


Solution

  • I have this function to get the complete url - the "QUERY_STRING" portion should give you the parameters

      FUNCTION request_url RETURN VARCHAR2
      IS
        l_url VARCHAR2(1024);
      BEGIN
        l_url := owa_util.get_cgi_env('SERVER_NAME') ||':' ||
               owa_util.get_cgi_env('SERVER_PORT') ||
               owa_util.get_cgi_env('SCRIPT_NAME') ||
               owa_util.get_cgi_env('PATH_INFO') ||
               owa_util.get_cgi_env('QUERY_STRING');
        RETURN l_url;
      EXCEPTION WHEN VALUE_ERROR THEN
        RETURN 'unable to retrieve request_url';
      END request_url;