Commits

Anonymous committed 4bceb65

Automated commit message

Comments (0)

Files changed (1)

DispatchConfiguration.wiki

 The {{{ resource }}} is an atom identifying a [[WebmachineResources|resource]] that should handle a matching request. It will have the {{{ args }}} (which must be a list) passed to its init function before request handling begins. 
 
 In the default directory structure for a new webmachine application, the dispatch terms will be in file:consult form in "priv/dispatch.conf" under the application root.
+
+=== Examples ===
+
+The examples below are taken from [[http://www.erlang-factory.com/conference/SFBayAreaErlangFactory2009/speakers/justinsheehy|Justin Sheehy's slide at Erlang Factory 2009]]
+
+|=Dispatch Rule                       |=URL     |=wrq:disp_path |=wrq:path  |=wrq:path_info |=wrq:path_tokens |
+|{["a"],           some_resource, []} |/a       |""             |"/a"       |[]              |[]              |
+|{["a", '*'],      some_resource, []} |/a       |""             |"/a"       |[]              |[]              |
+|{["a", '*'],      some_resource, []} |/a/b/c   |"b/c"          |"/a/b/c"   |[]              |["b", "c"]      |
+|{["a", foo],      some_resource, []} |/a/b     |""             |"/a/b"     |[{foo, "b"}]    |[]              |
+|{["a", foo, '*'], some_resource, []} |/a/b     |""             |"/a/b"     |[{foo, "b"}]    |[]              |
+|{["a", foo, '*'], some_resource, []} |/a/b/c/d |"c/d"          |"/a/b/c/d" |[{foo, "b"}]    |["c", "d"]      |
+
+Query strings are easy too:
+* Given rule: {["a", foo, '*'], some_resource, []}
+* And URL: /a/b/c/d?fee=ah&fie=ha
+* Then wrq:get_qs_value("fie",ReqData) -> "ha"