Skip to content
Newer
Older
100644 88 lines (51 sloc) 2.43 KB
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
1
2 <erl>
3
4
5 box(Str) ->
6 {'div',[{class,"box"}],
f6dbbc9 @klacke added possibility to name the module in a .yaws file
authored Mar 21, 2005
7 {pre,[], yaws_api:htmlize(Str)}}.
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
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) ->
20ece13 @klacke more css hackery
authored Dec 2, 2004
20 [{ssi, "TAB.inc", "%%",[{"appmods", "choosen"}]},
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
21 {ehtml,
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored Nov 19, 2004
22 {'div', [{id, "entry"}],
23
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
24 [{h1, [], "Appmods (Application modules)"},
25
26 {p, [],
0be3c7e @klacke untabified all of yaws
authored Feb 14, 2008
27 ["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"]},
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
28
29 box("http://yaws.hyber.org/pathelem/foo/bar/x.pdf"),
30
31 {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"]},
32
33
34 box("
35 <server tita>
0be3c7e @klacke untabified all of yaws
authored Feb 14, 2008
36 port = 8001
37 listen = 0.0.0.0
38 docroot = /home/klacke/yaws/yaws/scripts/../www
39 appmods = <pathelem, myappmod>
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
40 </server>"),
41
42
43
44
45 {p,[],
0be3c7e @klacke untabified all of yaws
authored Feb 14, 2008
46 ["Then the webserver would invoke ",
47 {tt,[], "myappmod:out(A)"},
48 " instead of trying to deliver the actual file. When shipping such an ",
49 {a, [{href, "/pathelem/foo/bar/x.pdf"}], "Url"},
50 " there are 2 fields in the #arg record which are especially interesting. If we have the following code in \"myappmod.erl\":"]},
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
51
52 ssi("code/myappmod.erl"),
53
54 {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."},
55
56
57 {p,[],
0be3c7e @klacke untabified all of yaws
authored Feb 14, 2008
58 "Thus the following url"},
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
59 box("http://yaws.hyber.org/zap/pathelem/foo/bar/x.pdf?a=b"),
60 {p,[],
0be3c7e @klacke untabified all of yaws
authored Feb 14, 2008
61 "Produces the following output:"},
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
62 box("
63 A#arg.appmoddata = \"/foo/bar/x.pdf\"
64 A#arg.appmod_prepath = \"/zap/\"
65 A#arg.querydata = \"a=b\""),
66
757eca1 @klacke ""
authored Dec 9, 2004
67 {br,[],[]},
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
68
69 {p, [],
0be3c7e @klacke untabified all of yaws
authored Feb 14, 2008
70 "Appmods would typically be used by webapplications that want to provide the illusion of proper paths to the browser. "}
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
71
72
bea8261 @klacke added log_wrap_size, configurable wrap size for all logs, fixed a bug…
authored Nov 19, 2004
73 ]
74 }},
75 {ssi, "END2",[],[]}
76 ].
e7aa877 @klacke documented appmods as an example
authored May 25, 2004
77
78
79
80 </erl>
81
82
83
84
85
86
87
Something went wrong with that request. Please try again.