Skip to content

wandenberg/nginx-let-module

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

----------------
NGINX let module
----------------

Adds support for arithmetic operations to NGINX config.

(c) 2011 Roman Arutyunyan, arut@qip.ru



Build:
======

Add this when configuring NGNIX:

./configure --add-module=$PATH_TO_MODULE




Examples:
=========

# adds variable $value equal to evaluated expression value

let $value ( $uid + 0x12 ) * $offset - 100 ;

let $remainer $number % 100 ;

let $welcome "Hi, " . $user . ", you have " . $num . " data items";
# echo $welcome ;

let_rand $randval from to;


IMPORTANT NOTE:

let-module uses NGINX config parser as lexer.
That means you should add spaces around each token.

let $value (1+2);             # ERROR!
let $value ( 1 + 2 );         # OK

let $value 1 + (2 * $uid);    # ERROR!
let $value 1 + ( 2 * $uid );  # OK



Features supported:
===================

- operations with unsigned integers:

  + - * / %

- string operations:

  . (concatenation)

- hexadecimal numbers

- grouping with parentheses



Notes:
======

Use the following command to rebuild parser generator if you need that

bison -d let.y

About

Provides support for arithmetic and string operations in NGINX config

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 90.4%
  • Yacc 6.0%
  • Nginx 3.6%