File: libraries.html

package info (click to toggle)
lua-wsapi 1.1.0-8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 400 kB
  • ctags: 171
  • sloc: ansic: 613; sh: 100; makefile: 30
file content (120 lines) | stat: -rw-r--r-- 4,270 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>WSAPI</title>
    <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>

<body>

<div id="container">

<div id="product">

	<div id="product_logo">
        <a href="http://wsapi.luaforge.net">
		<img alt="WSAPI" src="wsapi.png"/>
	    </a>
    </div>
	<div id="product_name"><big><strong>WSAPI</strong></big></div>
	<div id="product_description">Lua Web Server API</div>
</div> <!-- id="product" -->

<div id="main">
	
<div id="navigation">
<h1>WSAPI</h1>
	<ul>
		<li><a href="index.html">Home</a></li>
		<li><a href="manual.html">Manual</a></li>
		<li><strong>Libraries</strong></li>
		<li><a href="license.html">License</a></li>

	</ul>
</div> <!-- id="navigation" -->

<div id="content">


<h2>Overview</h2>

<p>WSAPI includes a set of helper libraries to make writing applications and web frameworks easier.
To use these libraries just <code>require</code> them in your application or framework.</p>

<h2>Request</h2>

<p><strong>wsapi.request.new(*wsapi_env<em>, [</em>options*])</strong> - creates a new request object wrapping *wsapi_env<em>; *options</em> is an (optional) table of extra options
for the request, the only option currently supported is *delay_post*, if set
this won't process the POST data on creation of the request</p>

<p><strong>req:parse<em>post</em>data()</strong> - processed the POST data in case the processing
was delayed by passing *delay_post = true* on creation of the request</p>

<p><strong>req.GET</strong> - table with GET parameters of request</p>

<p><strong>req.POST</strong> - table with POST parameters of request</p>

<p><strong>req.method</strong> - request method (usually "GET" or "POST") </p>

<p><strong>req.path_info</strong> - PATH_INFO metavariable</p>

<p><strong>req.script_name</strong> - SCRIPT_NAME metavariable</p>

<p><strong>req.query_string</strong> - unparsed query string</p>

<p><strong>req.params</strong> - union of <strong>req.GET</strong> and <strong>req.POST</strong>, built on demand</p>

<p><strong>req.cookies[<em>name</em>]</strong> - gets value of a cookie from browser</p>

<h2>Response</h2>

<p><strong>wsapi.response.new([<em>status</em>, <em>headers</em>, <em>body</em>])</strong> - creates a new response
object, optionally setting an initial status code, header table and body contents</p>

<p><strong>res.status</strong> - status code to be returned to server</p>

<p><strong>res.headers</strong> - table with headers to be returned to server</p>

<p><strong>res[<em>name</em>]</strong> - same as <strong>res.headers[<em>name</em>]</strong>, unless <em>name</em> is a field in res</p>

<p><strong>res[<em>name</em>] = <em>value</em></strong> - same as <strong>res.headers[<em>name</em>] = <em>value</em></strong>, unless <em>name</em> is
a field in res</p>

<p><strong>res:write(<em>s</em>)</strong> - adds <em>s</em> to the body if it is a string, if it is a table
concatenate the contents of the table and add to the body</p>

<p><strong>res:set_cookie(<em>name</em>, <em>value</em>)</strong> - sets the value of a cookie</p>

<p><strong>res:delete_cookie(<em>name</em>)</strong> - erases a cookie from browser</p>

<p><strong>res:finish()</strong> - finishes response, returning status, headers and an iterator for the body</p>

<h2>Util</h2>

<p><strong>wsapi.util.url_encode(<em>s</em>)</strong> - encodes <em>s</em> according to RFC2396</p>

<p><strong>wsapi.util.url_decode(<em>s</em>)</strong> - decodes <em>s</em> according to RFC2396</p>

<p><strong>wsapi.util.make_rewindable(<em>wsapi_env</em>)</strong> - wraps <em>wsapi_env</em> in a new
environment that lets you process the POST data more than once. This new
environment's input object has a <em>rewind</em> method that you can call to allow you to read
the POST data again.</p>



</div> <!-- id="content" -->

</div> <!-- id="main" -->

<div id="about">
	<p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p>
</div> <!-- id="about" -->

</div> <!-- id="container" -->

</body>
</html>