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/ ...
Get Resource-Oriented Computing with NetKernel now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.