$ show matsumotory/ngx_mruby
The ngx_mruby repository provides an Nginx module that embeds the mruby interpreter, enabling Ruby scripting for Nginx request processing. It allows developers to write Nginx configuration directives, content handlers, and filters in Ruby, offering an alternative to Lua-based solutions like OpenResty. The repository bundles mruby and includes a set of mruby gems tailored for Nginx integration, such as socket and IO extensions. The architecture consists of the ngx_mruby C module that interfaces with Nginx's API and the mruby C API, along with a customized mruby build. Key entry points are Nginx directives like `mruby_content_handler` and `mruby_set`, which execute mruby code during specific request phases. The mruby API exposes Nginx-specific classes (e.g., `Nginx::Request`, `Nginx::SSL`) via the `ngx_mruby_mrblib` gem. Data flows involve Nginx hooking into request processing phases, invoking mruby code that can inspect and modify requests/responses, then continuing with Nginx's standard processing. While the codebase demonstrates solid engineering, it faces maintenance challenges due to dependency on specific versions of Nginx and mruby, and the use of an outdated base image in the Dockerfile. The ngx_devel_kit dependency provides reusable helpers for Nginx module development, such as variable handling and HTTP manipulation functions, which exhibit good craftsmanship and could be extracted for use in other Nginx modules.
The LLM identified 1 files worth highlighting for reuse:
Implements functions to handle Nginx complex values and variables, allowing modules to safely evaluate variables and parse dynamic values. It is isolated (only depends on Nginx core and ngx_devel_kit headers) and demonstrates the pattern of abstracting Nginx's variable handling for use in custom modules. This component can be extracted and used in any Nginx module with minimal modification.