App module example (e.g. implement a simple blogging system)

Hi,

I get the impression that Caddy v2 is an App platform in which one can just extend Caddy to implement domain-specific http handler to build a fully-fledged backend service. However, I am not able to find a decent example of how to implement that properly.

Say a personal blog system with 3 domain models. User, Post, Comment.

I don’t want to implement 3 separate directives for each of the models, since that requires 3 separate directives in the Caddyfile. I’d like to keep the config as simple as possible. Ideally, the config could be separated into 2 parts. One part is exposed to the end-user using the App, the other part is internal to the App developer.

Above is one of the examples when considering using Caddy to build a backend. Any pointer on where I can study it further?

Thanks
Tianzhou

Our docs have a complete example of an HTTP handler module: Extending Caddy — Caddy Documentation

If you want to make an App module, they’re even simpler, just implement Start() and Stop() methods.