Caddy as base for an application

I think to try to use caddy as base for a application because the http and tls handling is quite robust.

When I take a look into the doc Extending Caddy — Caddy Documentation and Architecture — Caddy Documentation isn’t there any hint how to run caddy inside a golang app.

Is this with v2 still possible as it was with v1

That hasn’t been a goal with the design of Caddy v2. We haven’t spent any time trying to make that viable/easy (may be possible in some roundabout way but we didn’t look into it).

Now, Caddy is architected around the config, so I’d recommend writing your app logic as an HTTP handler module and/or an App module; your HTTP handler can load your app with ctx.App("your_app_name") which can do anything you need, provide whatever kind of interface you want for the HTTP handler module to invoke based on your configured routes.

Using it this way gives you Caddy’s benefits of having an admin API for hot-swapping configs on the fly and gracefully reloading, etc.

1 Like

Instead of running Caddy inside your Go app, run your Go app inside of Caddy.

thank you for your answers. I will take a look into the app mechanism.


This topic was automatically closed after 60 days. New replies are no longer allowed.