Host API

What FeatherFly passes to your plugin at init.

During init, FeatherFly passes a HostApi struct:

  • api_version — must match FEATHERFLY_PLUGIN_API_VERSION
  • register_hook — register a lifecycle event callback
  • register_config_hook — register a config YAML mutation callback
  • register_request_hook — register request.intercept or middleware.inject
  • register_route — register a plugin HTTP route (GET/POST/PUT/PATCH/DELETE)
  • register_json_hook — register a JSON mutation callback
  • register_cloudpanel_hook — inspect, mutate, or cancel CloudPanel CLI commands
  • log_info — write an info line to the daemon log

Register hooks only inside init. Callback pointers are kept until shutdown.

init return codes: 0 = success. Any other value fails plugin load.

Return codes:

  • CONFIG_MUTATE_MODIFIED / JSON_MUTATE_MODIFIED (0) — output written via write_* helpers
  • CONFIG_MUTATE_UNCHANGED / JSON_MUTATE_UNCHANGED (1) — keep input unchanged
  • REQUEST_CONTINUE (0) — pass request to next hook/handler
  • REQUEST_RESPOND (1) — short-circuit with write_request_response
  • ROUTE_OK (0) — route handled via write_route_response
  • CLOUDPANEL_CONTINUE / CLOUDPANEL_MODIFIED / CLOUDPANEL_CANCEL — continue, replace args, or block a CloudPanel command
  • Negative — error; input is kept

Output helpers

FunctionHook
write_yaml_outputconfig.mutate
write_request_responserequest.intercept / middleware.inject
write_route_responseroute.register
write_json_outputjson.response / json.actions
write_cloudpanel_args / write_cloudpanel_cancelcloudpanel.command

See macros and return codes.

Runtime inspection

GET /api/system/plugins — lists loaded plugins, hook counts, request phases, and route count. Handler source ↗