Name

December 16, 2019 · View on GitHub

ngx_cpp_dev

Nginx cpp development kit, with the power of C++11 and Boost Library.

Build Status

Table of Contents

Status

Experimental but works well.

Now support Nginx 1.13.10 and later.

See Also

Requirements

  • Linux or other UNIX like
  • C++11(gcc 4.6 or later)
  • Boost(1.57 or later)
  • Nginx 1.13.10 or later

Please see directiory "setup".

Usage

At first, you must patch nginx/auto/make to enable g++ compiler and C++11.

Please see directory "patch/auto".

For example:

patch -b make make.patch

Then configure nginx with:

./configure --add-module=path/to/ngxpp	\	            # ngx cpp module
			--add-module=xxxx			                # other modules
make

ngx_cpp_module is a pure header library, you should use ngx_cpp_module like this:

#include "NgxAll.hpp"	// include all C++ tools for http modules

Or

#include "NgxStreamAll.hpp"	// include all C++ tools for stream modules

Examples

Please see directory http, including echo/filter/variables and so on.

C++ APIs

common tools

Class NameDescription
NgxUnsetValuegeneric unset value -1.
NgxValuewrapper for nginx int, include init/merge/unset.
NgxExceptionwrapper for nginx error code.
NgxPoolwrapper for nginx memory pool.
NgxAlloctoradapter to C++ allocator.
NgxStringwrapper for nginx ngx_str_t.
NgxClockwrapper for nginx time functions.
NgxDatetimewrapper for nginx date functions.
NgxLogwrapper for nginx error log.

data structure

Class NameDescription
NgxArraywrapper for nginx ngx_array_t.
NgxListwrapper for nginx ngx_list_t.
NgxQueuewrapper for nginx ngx_queue_t.
NgxBufdeprecated, wrapper for nginx ngx_buf_t.
NgxChaindeprecated, wrapper for nginx ngx_chain_t.
NgxRbtreewrapper for nginx ngx_rbtree_t.

modules

Class NameDescription
NgxModuleConfigeasy to access nginx module confing info.
NgxModuleget module's config and ctx data.
NgxCommanddeprecated, DO NOT USE IT.
NgxTakedeprecated
NgxModuleCtxeasy to access nginx module's ctx data.
NgxHttpCoreModulewrapper for ngx_http_core_module
NgxFilterwrapper for nginx filter mechanism.

http process

Class NameDescription
NgxHeaders
NgxRequest
NgxResponse
NgxUpstreamHelper
NgxLoadBalance
NgxSubRequest

others

Class NameDescription
NgxVariables
NgxVarManager
NgxDigest
NgxTimer

TODO

  • more test suites
  • nginx datagram
  • ...