caddy icon indicating copy to clipboard operation
caddy copied to clipboard

Make the Admin API extensible

Open yroc92 opened this issue 3 years ago • 2 comments

I needed to execute some behavior upon configuration via the admin API. I did this by creating a module in the admin.api.<module> namespace with the help of @mholt. This is undocumented and not officially supported.

Here are some items to consider if Caddy were to support extending the Admin API based on my experience writing this unsupported module:

  • I'd like to be able to add config values like I can with normal modules
  • As such, we'd need to have "provision" and "validate" methods (making this a true CaddyModule)
  • It'd be nice if the methods found in load.go were public so they could be re-used (e.g. adaptByContentType, handleLoad)
  • We might consider dropping the Routes method for the interface and instead requiring that the route & handler be defined in the config?

yroc92 avatar Sep 10 '22 20:09 yroc92

We might consider dropping the Routes method for the interface and instead requiring that the route & handler be defined in the config?

I'm not a fan of this. I think it makes sense for plugins to provide specific well known endpoints instead of requiring users to set that up for themselves. That's important for documentation and examples, etc.

But yeah, making it a proper module makes sense. I think this is "my fault" because I set up this wiring for the proxy upstreams API (and later reused it for PKI app)

francislavoie avatar Sep 10 '22 23:09 francislavoie

Yeah, our admin API could use better extensibility design. Hence it's undocumented for now.

I want to revisit this after the 2.6 release. Definitely could be useful to have!

mholt avatar Sep 11 '22 02:09 mholt