caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
58.71k stars 4.05k forks source link

Make the Admin API extensible #5032

Open yroc92 opened 2 years ago

yroc92 commented 2 years ago

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:

francislavoie commented 2 years ago

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)

mholt commented 2 years ago

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!