.Headers [] string similar to .Env in template action


Today I used the https://caddyserver.com/docs/templates and wanted to print all Headers but there isn’t such a function like .Env

{{range $field, $val := .Env}}
{{$field}}: {{$val}}

Is there any plan to add this?

br aleks

Hey Aleks, good question. There’s an example on the template actions page:

{{range $field, $val := .Req.Header}}
    {{$field}}: {{$val}}

That should do something like what you want!

I could probably expand those docs a bit. Will note that for the future.

Thanks matt.

sorry for the rush. I have read this jus before I got to bed ;-/
Please accept my apologize for the useless question.

and wit works :wink:


The used dockerfile and templates are at this repo

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.