Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 86 lines (49 sloc) 2.301 kb
e7aa877 @klacke documented appmods as an example
authored
1
2 <erl>
3
4
5 box(Str) ->
6 {'div',[{class,"box"}],
7 {pre,[],Str}}.
8
9 tbox(T) ->
10 box(lists:flatten(io_lib:format("~p",[T]))).
11
12
13 ssi(File) ->
14 {'div',[{class,"box"}],
15 {pre,[],
16 {ssi, File,[],[]}}}.
17
18
19 out(A) ->
20 [{ssi, "HEAD", [],[]},
21 {ssi, "EXHEAD", [],[]},
22 {ehtml,
23 [{h1, [], "Appmods (Application modules)"},
24
25 {p, [],
26 ["Appmods are a way to let the application programmer take control over the URL path. Or put in another way, to let the application programmer fake real paths in URLs where in reality an Erlang modules is executing. Possibly an example make this easy to understand. Say we have the folowing url"]},
27
28 box("http://yaws.hyber.org/pathelem/foo/bar/x.pdf"),
29
30 {p,[],["With the above url, the webserver would try to deliver the file \"foo/bar/x.pdf\" relative to the docroot. However if we had specified \"pathelem\" as an appmod, the server would stop processing the url after seeing the \"pathelem\" part of the URL. Say we had the following in our yaws.conf configuration file"]},
31
32
33 box("
34 <server tita>
35 port = 8001
36 listen = 0.0.0.0
37 docroot = /home/klacke/yaws/yaws/scripts/../www
38 appmods = <pathelem, mymod>
39 </server>"),
40
41
42
43
44 {p,[],
45 ["Then the webserver would invoke ",
46 {tt,[], "myappmod:out(A)"},
47 " instead of trying to deliver the actual file. When shipping such an ",
48 {a, [{href, "/pathelem/foo/bar/x.pdf"}], "Url"},
49 " there are 2 fields in the #arg record which are especially interesting. If we have the following code in \"myappmod.erl\":"]},
50
51 ssi("code/myappmod.erl"),
52
53 {p,[],"The #arg field called \"appmoddata\" contains the remainder of the path following the encountered appmod and the field \"appmod_prepath\" contains the part of the URL path leading upto the appmod."},
54
55
56 {p,[],
57 "Thus the following url"},
58 box("http://yaws.hyber.org/zap/pathelem/foo/bar/x.pdf?a=b"),
59 {p,[],
60 "Produces the following output:"},
61 box("
62 A#arg.appmoddata = \"/foo/bar/x.pdf\"
63 A#arg.appmod_prepath = \"/zap/\"
64 A#arg.querydata = \"a=b\""),
65
66 {br},
67
68 {p, [],
69 "Appmods would typically be used by webapplications that want to provide the illusion of proper paths to the browser. "}
70
71
72 ]}].
73
74
75
76 </erl>
77
78
79 </html>
80
81
82
83
84
85
Something went wrong with that request. Please try again.