da38aba509
Refactor code into separate modules with clear boundaries
...
Code Organization:
- src/config.rs (133 lines): Configuration structs and merge implementations
- src/query.rs (327 lines): SQL query execution with parameter binding
- src/template.rs (160 lines): Template loading and management
- src/variable.rs (107 lines): Nginx variable resolution utilities
- src/lib.rs (387 lines): Module registration and directive handlers
Benefits:
✓ Single responsibility per module
✓ Better testability (tests co-located with code)
✓ Clearer separation of concerns
✓ Easier maintenance and debugging
✓ Reduced cognitive load (smaller files)
Module Breakdown:
config.rs:
- ModuleConfig (location-level config)
- MainConfig (HTTP-level config)
- Merge trait implementations
- 5 configuration tests
query.rs:
- execute_query() with named/positional parameter support
- Row-to-JSON conversion logic
- 7 query execution tests (data types, params, LIKE, etc.)
template.rs:
- load_templates_from_dir() for auto-discovery
- Template registration and override handling
- 3 template system tests
variable.rs:
- resolve_variable() for nginx variable access
- resolve_nginx_variable() using ngx_http_get_variable FFI
- 3 parameter handling tests
lib.rs:
- Module trait implementations (HttpModule, HttpModuleLocationConf, HttpModuleMainConf)
- nginx module registration (ngx_modules! macro)
- Command array and directive handlers
- HTTP request handler (tightly coupled with Module)
Test Coverage: 20 tests across all modules
All tests passing. Module verified working in production.
2025-11-15 15:38:20 -08:00