Commit Graph

93 Commits

Author SHA1 Message Date
Thierry FOURNIER
12a865dc24 DOC: lua: improve links
Sphinx provide a method for generating hyperlink between some references.
This patch uses these methods for internal links.
2016-12-15 12:05:07 +01:00
Thierry FOURNIER
a78f037505 DOC: lua: documentation about time parser functions
This patch must be backported in version 1.7
2016-12-15 12:04:52 +01:00
Thierry FOURNIER / OZON.IO
c1edafe4a9 DOC: lua: Add documentation about variable manipulation from applet
This patch adds documentation about set_var, unset_var and get_var
functions added in the Class AppletHTTP and AppletTCP.
2016-12-12 17:30:49 +01:00
Thierry FOURNIER / OZON.IO
b210bcc559 DOC: lua: Documentation about some entry missing
The parameter "value" of the function TXN.set_var() was not documented.

This is a regression from the commit 85d79c94a9.
This patch must be backported in 1.7
2016-12-12 17:29:40 +01:00
Thierry FOURNIER / OZON.IO
8a1027aa45 MINOR: lua: Add tokenize function.
For tokenizing a string, standard Lua recommends to use regexes.
The followinf example splits words:

   for i in string.gmatch(example, "%S+") do
      print(i)
   end

This is a little bit overkill for simply split words. This patch
adds a tokenize function which quick and do not use regexes.
2016-11-24 21:35:34 +01:00
Thierry FOURNIER / OZON.IO
a44fdd95f9 MEDIUM: lua: Add cli handler for Lua
Now, HAProxy allows to register some keys in the "cli". This patch allows
to handle these keys with Lua code.
2016-11-18 14:32:03 +01:00
Thierry FOURNIER / OZON.IO
62fec75183 MINOR: lua: add ip addresses and network manipulation function
Add two functions core.parse_addr() and core.match_addr() where are used
for matching networks.
2016-11-12 10:42:30 +01:00
Thierry FOURNIER / OZON.IO
65192f35d2 MINOR: lua: add function which return true if the channel is full.
Add function which return true if the channel is full. It is
useful for triggering some process when the buffer is full.
2016-11-12 10:42:25 +01:00
Christopher Faulet
85d79c94a9 MINOR: vars: Add 'unset-var' action/converter
It does the opposite of 'set-var' action/converter. It is really useful for
per-process variables. But, it can be used for any scope.

The lua function 'unset_var' has also been added.
2016-11-09 22:57:01 +01:00
Thierry FOURNIER / OZON.IO
53e381c3a0 DOC: lua: remove old functions
The functions "req_replace_value()" and "res_replace_value()"
doesn't exists in the 1.6 version. There inherited from the 1.6dev.

This patch must be backported in 1.6 version
2016-08-03 00:05:59 +02:00
Thierry FOURNIER
ab00df6cf6 BUG/MEDIUM: lua: the function txn_done() from sample fetches can crash
The function txn_done() ends a transaction. It does not make
sense to call this function from a lua sample-fetch wrapper,
because the role of a sample-fetch is not to terminate a
transaction.

This patch modify the role of the fucntion txn_done() if it
is called from a sample-fetch wrapper, now it just ends the
execution of the Lua code like the done() function.

Must be backported in 1.6
2016-07-14 16:14:24 +02:00
Thierry Fournier
ff480424ab MINOR: lua: add class listener
This class provides the access to the listener struct, it allows
some manipulations and retrieve informations.
2016-03-30 18:43:47 +02:00
Thierry Fournier
f2fdc9dc39 MINOR: lua: add class server
This class provides the access to the server struct, it allows
some manipulations and retrieve informations.
2016-03-30 18:43:47 +02:00
Thierry Fournier
f61aa6356e MINOR: lua: add class proxy
This class provides the access to the proxy struct, it allows
some manipulations and retrieve informations.
2016-03-30 18:43:42 +02:00
Thierry Fournier
eea77c0e17 MINOR: lua: dump general info
This patch adds function able to dump general haproxy information.
2016-03-30 17:27:40 +02:00
Thierry Fournier
1de1659923 MINOR: lua: Add concat class
This patch adds the Concat class. This class provides a fast
way for the string concatenation.
2016-02-12 11:08:53 +01:00
Thierry Fournier
b1f46561a0 MINOR: lua: add "now" time function
This function returns the current time in the Lua.
2016-02-12 11:08:53 +01:00
Thierry FOURNIER
834421c2d0 DOC: lua: fix somme errors
This patch fix some errors in the class TXN doc.

Should be backported in 1.6
2016-02-11 19:30:28 +01:00
Thierry FOURNIER
8db004cbf4 MINOR: lua: add set/get priv for applets
The applet can't have access to the session private data. This patch
fix this problem. Now an applet can use private data stored by actions
and fecthes.
2015-12-25 10:34:28 +01:00
Thierry FOURNIER
e34a78e5ce DOC: lua: fix somme errors and add implicit types
This patch fix some errors and adds implicit types for AppletHTTP
and AppletTCP.

Should be backported in 1.6
2015-12-25 10:34:08 +01:00
Thierry FOURNIER
dc595009b6 DOC: lua: fix lua API
This patch fix the Lua API documentation, and adds some internal link
between values returned and associated class.

This patch can be backported in 1.6.
2015-12-21 22:17:24 +01:00
Thierry FOURNIER
841475e304 MINOR: lua: service/applet can have access to the HTTP headers when a POST is received
When a POST is processed by a Lua service, the HTTP header are
potentially gone. So, we cannot retrieve their content using
the standard "hdr" sample fetchs (which will soon become invalid
anyway) from an applet.

This patch add an entry "headers" to the object applet_http. This
entry is an array containing all the headers. It permits to use the
HTTP headers during the processing of the service.

Many thanks to Jan Bruder for reporting this issue with enough
details to reproduce it.

This patch will have to be backported to 1.6 since it will be the
only way to access headers from Lua applets.
2015-12-20 23:12:12 +01:00
Pieter Baauw
4d7f766b6d DOC: lua-api/index.rst small example fixes, spelling correction.
[wt: backport to 1.6]
2015-11-09 11:14:54 +01:00
David Carlier
61fdf8baa4 DOC: lua: few typos. 2015-10-02 23:06:42 +02:00
Thierry FOURNIER
a2d02253cf DOC: lua: update doc according with the last Lua changes
The impact of the register_action() was not repported.
2015-10-02 22:56:11 +02:00
Pieter Baauw
2dcb9bc5bf DOC: fix lua use-service example 2015-10-02 00:53:57 +02:00
Willy Tarreau
61add3c064 DOC: fix some broken unexpected unicode chars in the Lua doc.
A few chars didn't render properly in some terminals and had no
reason for being there.
2015-09-28 15:39:10 +02:00
Thierry FOURNIER
a3bc513a23 DOC: lua: some documentation update
this update embbeds some fix of existing function, and the applet documentation.
2015-09-28 15:23:57 +02:00
Thierry FOURNIER
8255a75e08 MINOR: lua: change actions registration
The current Lua action are not registered. The executed function is
selected according with a function name writed in the HAProxy configuration.

This patch add an action registration function. The configuration mode
described above disappear.

This change make some incompatibilities with existing configuration files for
HAProxy 1.6-dev.
2015-09-23 21:44:23 +02:00
Willy Tarreau
bc183a6eda DOC: lua: mention than txn:close was renamed txn:done.
Also indicate that it's not limited to error processing.
2015-08-28 10:39:11 +02:00
Willy Tarreau
99a36dddf5 DOC: lua: replace txn:close with txn:done in lua-api
It was missed in the last patch.
2015-08-27 14:57:30 +02:00
Thierry FOURNIER
35d70efc33 MINOR: http: Action for manipulating the returned status code.
This patch is inspired by Bowen Ni's proposal and it is based on his first
implementation:

   With Lua integration in HAProxy 1.6, one can change the request method,
   path, uri, header, response header etc except response line.
   I'd like to contribute the following methods to allow modification of the
   response line.

   [...]

   There are two new keywords in 'http-response' that allows you to rewrite
   them in the native HAProxy config. There are also two new APIs in Lua that
   allows you to do the same rewriting in your Lua script.

   Example:
   Use it in HAProxy config:
   *http-response set-code 404*
   Or use it in Lua script:
   *txn.http:res_set_reason("Redirect")*

I dont take the full patch because the manipulation of the "reason" is useless.
standard reason are associated with each returned code, and unknown code can
take generic reason.

So, this patch can set the status code, and the reason is automatically adapted.
2015-08-27 14:29:44 +02:00
Thierry FOURNIER
0d79cf686b DOC: fix function name
Bowen repports this typo fix about one Lua function name.

Reported-By: Bowen
2015-08-27 11:29:45 +02:00
Thierry FOURNIER
0a99b89531 MINOR: lua: add core.done() function
This function immediately give back the control to HAProxy core.
2015-08-27 11:27:29 +02:00
Pieter Baauw
386a127ff0 DOC: match several lua configuration option names to those implemented in code 2015-08-19 01:39:50 +02:00
Thierry FOURNIER
053ba8adfd MINOR: lua: Variable access
This patch adds two Lua function for using HAPRoxy's
vraibles. The function are stored in the TXN class,
and her name is "set_var" and "get_var".
2015-06-13 23:01:37 +02:00
Thierry FOURNIER
3def393f8d MINOR: lua: map system integration in Lua
This patch cretes a new Map class that permits to do some lookup in
HAProxy maps. This Map class is integration in the HAProxy update
system, so we can modify the map throught the socket.
2015-04-07 15:56:21 +02:00
Thierry FOURNIER
2e4893cb7f DOC: lua: some fixes
- remove trailing spces
 - update fetches ans converters documentation
2015-04-07 15:55:58 +02:00
Thierry FOURNIER
c798b5d282 MINOR: lua: add log functions
Thispatch adds global log function. Each log message is writed on
the stderr and is sent to the default syslog server. These two
actions are done according the configuration.
2015-03-18 11:34:06 +01:00
Thierry FOURNIER
486f5a059a DOC: lua: fix some typos
The class name before the function doesn't have the same
syntax than the declared class names.

The return code is not declared in the prototype of the function.

After the last API modification, the hello world example does not
yet run.
2015-03-18 11:34:06 +01:00
Thierry FOURNIER
08504f4e19 MINOR: lua: create and register HTTP class
This class is accessible via the TXN object. It is created only if
the attached proxy have HTTP mode. It contain all the HTTP
manipulation functions:

 - req_get_headers
 - req_del_header
 - req_rep_header
 - req_rep_value
 - req_add_header
 - req_set_header
 - req_set_method
 - req_set_path
 - req_set_query
 - req_set_uri

 - res_get_headers
 - res_del_header
 - res_rep_header
 - res_rep_value
 - res_add_header
 - res_set_header
2015-03-18 11:34:06 +01:00
Thierry FOURNIER
2cce3538ca MINOR: lua: txn: add function set_(loglevel|tos|mark)
This patch adds the "loglevel", "tos" and "mark" manipulation related to
one transaction.
2015-03-18 11:34:06 +01:00
Thierry FOURNIER
17bd152b58 DOC: lua api
This contains the Lua API documentation and the build environment
for Sphinx.
2015-03-11 20:41:33 +01:00