config.mutate

Rewrite config YAML before FeatherFly applies settings.

When
After all plugins init, before directories/logging/pid are created.
Input
Raw config.yml bytes from disk.
Output
Replacement YAML bytes via write_yaml_output.
Route matching
N/A — global config pipeline, not route-scoped.

Use to inject defaults, strip keys, or apply environment-specific overrides. Output must remain valid YAML. Invalid output keeps the prior bytes. Register with hook_config! during init.

Pipeline

Runs in plugin load order. Each hook receives the previous hook's output.

Use cases

  • Inject default plugin paths per environment
  • Strip development-only keys in production
  • Merge secrets from external sources into YAML

Example

Registration and handler

Register

hook_config!(host, on_config_mutate);

Handler

extern "C" fn on_config_mutate(ctx: *const ConfigMutateContext) -> i32 {
    let ctx = unsafe { &*ctx };
    let input = unsafe { std::slice::from_raw_parts(ctx.yaml_in_ptr, ctx.yaml_in_len) };
    let mut out = input.to_vec();
    out.extend_from_slice(b"\nplugins:\n  enabled: true\n");
    write_yaml_output(ctx, &out)
}

← Back to index