O'Reilly logo

Resource-Oriented Computing with NetKernel by Tom Geudens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix F. Examples and Solutions

Example—Limiter

A Limiter endpoint takes care of unwanted side effects in a space.[43]

Setup

Consider the following rootspace definition:

<rootspace 
  name="Limiter Demo - Services"
  public="true"
  uri="urn:org:netkernelbook:chapter2:limiter:services">
  <fileset>
    <regex>res:/etc/system/SimpleDynamicImportHook.xml</regex>
  </fileset>
  
  <fileset>
    <regex>res:/limiterdemo/(.*)</regex>
    <rewrite>res:/resources/$1</rewrite>
  </fileset>
</rootspace>

The functionality of this rootspace could be described as providing access to anything in the resources directory.

With the following content for SimpleDynamicImportHook.xml, that means you provide access to anything in the resources directory to the whole wide world.[44]

<connection>
  <type>HTTPFulcrum</type>
</connection>

Let us also create a couple of things in the resources directory. First, there’s a file limiter_demo_allowed.txt:

http://periodicvideos.com/
http://www.sixtysymbols.com/

There’s also a file limiter_demo_not_allowed.xml.

<general>
  <password>ThisIsThePasswordIUseEverywhere</password>
</general>

The solution

<rootspace name="Limiter Demo - Services" public="true" uri="urn:org:netkernelbook:chapter2:limiter:services"> <fileset> <regex>res:/etc/system/SimpleDynamicImportHook.xml</regex> </fileset> <fileset> <regex>res:/limiterdemo/(.*)</regex> <rewrite>res:/resources/$1</rewrite> </fileset> <endpoint> <prototype>Limiter</prototype> <grammar>res:/limiterdemo/ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required