Web / Caddy Server Interview questions
Explain the internal working of Caddy's module system?
Caddy is built around a small core plus a registry of modules, rather than one monolithic codebase. Every non-trivial capability - HTTP handlers, TLS storage backends, log encoders, matchers - is a Go type that implements a specific interface and registers itself with caddy.RegisterModule under a dotted namespace, such as http.handlers.reverse_proxy or tls.certificates.load_folder.
At build time, xcaddy imports the desired module packages so their init() functions run and populate the registry inside the compiled binary. At runtime, the JSON config references a module purely by its namespace string (for example "handler": "reverse_proxy" inside the http.handlers namespace); Caddy looks that string up in the registry, constructs an instance, and wires it into the request pipeline. This is why adding a capability to Caddy - like a new DNS provider or a rate limiter - never touches Caddy's own source code, only the list of modules compiled in.
More Related questions...