# We use $root_ds as the httpd space. let ?root_ds = dataspace # Supplying $root_ds as the last parameter in this relay-listener enables httpd service. $gatekeeper $root_ds>> # Regular gatekeeper stuff works too. $root_ds #f> # Create an httpd router monitoring $root_ds for requests and bind requests. > # Create a static file server. When it gets a request, it ignores the first n (here, 1) # elements of the path, and takes the remainder as relative to its configured directory (here, # "."). # > # # It publishes a service object: requests should be asserted to this. # The http-bind record establishes this mapping. # ? ?handler> [ $root_ds += ] # Separately, bind path /d to $index, and respond there. # let ?index = dataspace $root_ds += $index ? [ $k ! $k !
$k ! "> $k ! D"> ] # Similarly, bind three paths, /d, /e and /t to $index2 # Because /d doubles up, the httpd router gives a warning when it is accessed. # Accessing /e works fine. # Accessing /t results in wasted work because of the hijacking listeners below. # let ?index2 = dataspace $root_ds += $root_ds += $root_ds += $index2 ? [ $k ! $k !
$k ! "> $k ! D2"> ] # These two hijack /t by listening for raw incoming requests the same way the httpd router # does. They respond quicker and so win the race. The httpd router's responses are lost. # $root_ds ? ?k> [ $k ! $k !
$k ! T"> ] $root_ds ? ?k> [ $k ! $k !
$k ! T2"> ]