I’m looking at two versions static_resource:init/1 in two Webmachine applications:
https://github.com/basho/wriaki/blob/master/apps/wriaki/src/session_resource.erl
http://lambder.com/2009/06/providing-static-content-in-webmachine/
In both cases the parameter passed into static_resource:init/1 is DocRoot. But I can’t find where this function is set or DocRoot is defined.
Can anyone point me toward an answer?
Many thanks,
LRP
I had a look at the webmachine_demo_fs_resource from here, and it appears that the value passed to
init/1is set in thedispatch.conf. As you can see here the last parameter of the config forwebmachine_demo_fs_resourceis[{root, "/tmp/fs"}], which specifies the doc root. Of course you can label the properties however you like, so long as you read them out in the same way ininit/1.This explains how the demos work, however that may or may not be the right thing to do from the perspective of your application. Maybe you want to read an environment variable or a boot arg to figure out where your doc root should be. For example:
You can set the
Contextvalue to be whatever you like, so you can choose your own adventure!