Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 56 lines (47 sloc) 2.501 kb
72a97f4 Roberto Ostinelli
authored
1 % ==========================================================================================================
cbde979 Roberto Ostinelli
authored
2 % MISULTIN - Example: Gets the GET variable 'value' and prints it out as XML if found.
dc565e4 Roberto Ostinelli added stream example
authored
3 %
4 % >-|-|-(°>
72a97f4 Roberto Ostinelli
authored
5 %
b6f5286 Roberto Ostinelli - added max_connections options parameter, which specifies maximum concu...
authored
6 % Copyright (C) 2011, Roberto Ostinelli <roberto@ostinelli.net>
72a97f4 Roberto Ostinelli
authored
7 % All rights reserved.
8 %
9 % BSD License
10 %
11 % Redistribution and use in source and binary forms, with or without modification, are permitted provided
12 % that the following conditions are met:
13 %
14 % * Redistributions of source code must retain the above copyright notice, this list of conditions and the
15 % following disclaimer.
16 % * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
17 % the following disclaimer in the documentation and/or other materials provided with the distribution.
18 % * Neither the name of the authors nor the names of its contributors may be used to endorse or promote
19 % products derived from this software without specific prior written permission.
20 %
21 % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
22 % WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 % PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
24 % ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25 % TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 % HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 % NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 % POSSIBILITY OF SUCH DAMAGE.
29 % ==========================================================================================================
30 -module(misultin_get_variable).
b5e0272 Roberto Ostinelli primary websockets support added.
authored
31 -export([start/1, stop/0]).
72a97f4 Roberto Ostinelli
authored
32
a483d2e Roberto Ostinelli modified examples to have a configurable port.
authored
33 % start misultin http server
34 start(Port) ->
35 misultin:start_link([{port, Port}, {loop, fun(Req) -> handle_http(Req) end}]).
72a97f4 Roberto Ostinelli
authored
36
37 % stop misultin
38 stop() ->
39 misultin:stop().
40
41 % callback on request received
42 handle_http(Req) ->
43 % get params
44 Args = Req:parse_qs(),
7808ed9 Roberto Ostinelli added helper function to get value from variable.
authored
45 case Req:get_variable("value", Args) of
72a97f4 Roberto Ostinelli
authored
46 undefined ->
39493dc Roberto Ostinelli reengineering of the listener process, using active instead of passive m...
authored
47 Req:ok([{"Content-Type", "text/xml"}], "<misultin_test><error>no value specified</error></misultin_test>");
87523c6 Roberto Ostinelli - added flow control using inet options {active, once} [issue track #1, ...
authored
48 Value ->
39493dc Roberto Ostinelli reengineering of the listener process, using active instead of passive m...
authored
49 Req:ok([{"Content-Type", "text/xml"}], "<misultin_test><value>~s</value></misultin_test>", [Value])
72a97f4 Roberto Ostinelli
authored
50 end.
51
52
53
54
55
Something went wrong with that request. Please try again.