Determine the URL associated with a request without resorting to request headers.

What should I do for the URL of a request without resorting to what the caller to set the request headers X-APEX-PATH and X-APEX-BASE?

Is a variable binding available?  I tried: url and: uri without success.

I would like this information in order to implement HATEOAS features; to return the "parent" of the current URL or other URL are not children of the URL of the request, but it can be derived related.  For example, the URL of the https://server:port / xxx/account/abc123/recipes/zxy987 I wish I could return a URL reference for all bills paid (see example below).  If there is another, or better, medium provided by ADR interested.

Thank you.

{

"items":]

"uri": {}

        "$ref": " Https://Server:port / ADR/account/abc123/ERC/RXYZ987 "

},

"receipt_number": "RXYZ987",

"receipt_date": "2015-01 - 02 T 08: 00:00Z"

'amount': ' $249,00 ",

"bills":]

{

"invoice_number": "INV123",

'total': ' $149,00 ",

"uri": {}

            "$ref": " Https://Server:port / ADR/account/abc123/invs/INV123 "

}

},

{

"invoice_number": "INV130",

"total": "$100.00". "

"uri": {}

            "$ref": " Https://Server:port / ADR/account/abc123/invs/INV130 "

}

}

]

]

}

Hi Ryan,

Well, getting back to your original question, there is a WAY BETTER way to build these hyperlink references.

In the documentation of the ADR ( http://docs.oracle.com/cd/E56351_01/doc.30/e56293/develop.htm#AELIG90013 ), we find the following paragraph:

Based on what I've created an example based on the EMP table:

set sqlblanklines on

declare
  l_moduleid   number;
  l_templateid number;
  l_handlerid  number;
begin
  -- delete module if exists
  ords_services.delete_module('URL-Sample');

  -- REST Modul anlegen
  l_moduleid := ords_services.create_module(
    p_name       => 'URL-Sample'
   ,p_uri_prefix => 'URL-Sample/'
   ,p_status     => 'PUBLISHED'
  );

  -- 1. URL-Template
  l_templateid := ords_services.add_template(
    p_module_id    => l_moduleid
   ,p_uri_template => 'employees/'
  );

  --------------------------------------
  -- GET Handler to retrieve a full list of all employees
  -- GET URL-Sample/employees/
  --------------------------------------
  l_handlerid := ords_services.add_handler(
    p_template_id  => l_templateid
   ,p_source_type  => ords.source_type_collection_feed
   ,p_source       => q'[

   select empno "$self", emp.* from emp

   ]'
   ,p_method       => 'GET'
   ,p_items_per_page => 100
  );  

  -- 2. URL-Template
  l_templateid := ords_services.add_template(
    p_module_id    => l_moduleid
   ,p_uri_template => 'employees/{empno}'
  );

  --------------------------------------
  -- GET Handler to retrieve a single employee
  -- GET URL-Sample/employees/{empno}
  --------------------------------------
  l_handlerid := ords_services.add_handler(
    p_template_id  => l_templateid
   ,p_source_type  => ords.source_type_query
   ,p_source       => q'[

   select empno "$uri",
       '../employees/' "$collection",
       '../../metadata-catalog/handler-test/feed/' "$describedby",
       emp.*
  from emp
 where empno=:empno

   ]'
   ,p_method       => 'GET'
  );  

end;
/

commit
/

/*=======================================================================
  now we can test the service using :

  *) GET a list of contacts:
  curl -i http://localhost:8080/ords/ordstest/URL-Sample/employees/

  *) GET a single contact:
  curl -i http://localhost:8080/ords/ordstest/URL-Sample/employees/7782

=======================================================================*/ 

When you run this you get the following results:

Especially note here that you are working with absolute and relative paths here (using a relative path syntax in a directory tree:... /..).

The feature is really cool... If it was established only the most obviously.

It's a shame.

I used in this example ords.source_type_query as a return type for a single employee. If I use ords.source_type_collection_item as return type, ADR will be actually build the reference to the parent that feed by itself:

It works for you?

~ Dietmar.

Tags: Database

Similar Questions

Maybe you are looking for

  • Sprout of HP: HP PC Hardware Diagnostics UEFI install faulty

    5 times the HP Support Assistant attempted to update the "HP PC Hardware Diagnostics UEFI". Whenever he fails. After each attempt, I made a stop and then tried again.

  • Wireless more

    I have a hp pavilion elite m9552p, Win7 desktop, which is not able to connect to my network more via the wireless running.  It will connect with an ethernet cable.  I just the words "an unexpected error has occurred" when I try to manually connect vi

  • What is lvanlys.dll?

    I have a build that always wants to include lvanlys.dll. What he calls? How do iremove it?

  • disruptive shutdown

    Computer closed Hi completely without warning to reliability all said that no material event viewer problem just disruptive stop does say that no critical problems temp monitor says the f 78 78 séptimo clocked motherboard down across runs of 5 HR lon

  • Why is my tiny impression 7520

    My 7520 is very small printing of web pages. How can it be solved?