I have implmented a custom module called my handler.
The module received one paramater, so the directive is caddyfile should look like this:
…
myhandler 50
…
I parse the parameters in the method:
func (f *Filter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
which is called from:
func parseCaddyfileHandler(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
f := &Filter{}
err := f.UnmarshalCaddyfile(h.Dispenser)
return f, err
}
loaded in the init function:
func init() {
rand.Seed(uint64(time.Now().UnixNano()))
f := Filter{}
caddy.RegisterModule(f)
httpcaddyfile.RegisterHandlerDirective("myhandler", parseCaddyfileHandler)
}
The problem is that the pointer in the UnmarshalCaddyfile method is different from the Provision method, so the caddyfile parameters does not propogate to provision (i.e. I set the parameter in the UnmarshalCaddyfile method, but it does not appear in the Provision).
What do I miss?