Skip to content

Creating services with slashes

alangrafu edited this page Feb 8, 2013 · 3 revisions

Creating services containing a /

Sometimes it is useful to have services that reflect a certain hierarchy. For example, imagine you have URIs describing information about a university with the following pattern:

http://example.org/id/SCHOOL/DEPARTMENT/RESEARCHGROUP

Thus, you may have

http://example.org/id/science/physics/highenergy
http://example.org/id/science/chemistry/polymers
http://example.org/id/science/chemistry/aminoacids
http://example.org/id/humanities/literature/medieval
http://example.org/id/humanities/cognitivescience/perceptionlab
http://example.org/id/humanities/cognitivescience/inference

An elegant mechanism to browse these URIs is providing a list of services like

  • http://example.org/id list all the schools
  • http://example.org/id/SCHOOL list all the departments related to this particular SCHOOL
  • http://example.org/id/SCHOOL/DEPARTMENT list all the research groups related to this particular SCHOOL and DEPARTMENT

In simple cases, this can be done easily by passing arguments to services, but when things start increasing in complexity and variety, it may be necessary to separate each listing into different services. Since version 20130206, it is possible to create services containing slashes /. This is done as usual by executing

utils/lodspk.sh create service id/science

This will create the folder components/services/id%27science (/ is encoded). Under this folder the files and directories for queries and templates are the same as always.

Priority of conflicting services

Since, it is possible to have a id and id/science service, LODSPeaKr will try to match first with the service with the longest name. Thus, when id/science/physics is requested, LODSPeaKr will ask:

  1. Is id/science/physics a service? if false then
  2. Is id/science a service? if false then
  3. Is id/ a service? if false then return false for the service module

This is the priority for the service module. See Modules and Changing priorities of modules for more information about how module priority works and how it can be changed.

Arguments in services with /

As you would expect, if there is a service id/science and an agent requests id/science/abc/123, the service will be able to use abc and 123 as arguments. See Passing arguments to services for more information.

See also

Clone this wiki locally