Hi @Basile_Alex, welcome to the Caddy community.
Looks like you’re trying to extend Caddy with middleware! You can find the documentation on how to do that here: https://github.com/mholt/caddy/wiki/Extending-Caddy
Give that wiki page a read and look further into the pages for Directives and HTTP Middleware, which outline the methods used by the header
code you linked.
I should note that Caddy doesn’t use or directly integrate with another net/http server, though. Depending on what your server does, instead of extending with middleware, you could run your Caddy instance with a proxy
directive to your own server listening on a local port.