Register a by-process lookup function with ap_expr
An important use case of mod_resolve is to put resolved values into request environment variables in order to use those inside expressions in the configuration (ap_expr).
Instead, the resolution could be triggered directly as part of the expression, removing the need to carefully configure the ResolveByProcess
to occur in the right stage.
ap_expr allows to register custom functions via a hook ap_run_expr_lookup
.
This function is called during evaluation and can resolve a string arg or list of string args to another string.
The relevant types in ap_expr.h are ap_expr_string_func_t
and ap_expr_string_list_func_t
.
Open Questions
-
What exactly is the interface for users in the configuration? Is it possible to pass several distinct arguments? How can this be mapped to the arguments passed to the process?
-
Most aspects by-process configuration should be pre-configured and accessed via an alias, so that only context-specific arguments are inserted inside the expression.
-
A resolve config may also contain expressions. How to handle recursive calls and is there a danger of infinite recursion?
-
Once this is established, the
ResolveByProcess
directive could be replaced by a more generic directiveSetByExpr
which can populate request environment variables, fields, ... by expressions in different stages. In the expression, a resolve function can be used. Is this level of freedom possible (see above for the question regarding the interface)? Can this still send custom error codes?