aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/headers/headers.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-05-22 12:32:36 -0600
committerMatthew Holt <[email protected]>2019-05-22 12:32:36 -0600
commitbc00d840e845d42145954839b88f1e836cd51bfd (patch)
tree0cd9f1103f3056fbadede6fd7de12ec605f50c02 /modules/caddyhttp/headers/headers.go
parentbe9b6e7b57d5bbf13d26b1620d34efc4e12284f7 (diff)
downloadcaddy-bc00d840e845d42145954839b88f1e836cd51bfd.tar.gz
caddy-bc00d840e845d42145954839b88f1e836cd51bfd.zip
Export types and fields necessary to build configs (for config adapters)
Also flag most fields with 'omitempty' for JSON marshaling
Diffstat (limited to 'modules/caddyhttp/headers/headers.go')
-rw-r--r--modules/caddyhttp/headers/headers.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/caddyhttp/headers/headers.go b/modules/caddyhttp/headers/headers.go
index e94fb54cb..4cab5b5cb 100644
--- a/modules/caddyhttp/headers/headers.go
+++ b/modules/caddyhttp/headers/headers.go
@@ -17,22 +17,22 @@ func init() {
// Headers is a middleware which can mutate HTTP headers.
type Headers struct {
- Request HeaderOps `json:"request"`
- Response RespHeaderOps `json:"response"`
+ Request *HeaderOps `json:"request,omitempty"`
+ Response *RespHeaderOps `json:"response,omitempty"`
}
// HeaderOps defines some operations to
// perform on HTTP headers.
type HeaderOps struct {
- Add http.Header `json:"add"`
- Set http.Header `json:"set"`
- Delete []string `json:"delete"`
+ Add http.Header `json:"add,omitempty"`
+ Set http.Header `json:"set,omitempty"`
+ Delete []string `json:"delete,omitempty"`
}
// RespHeaderOps is like HeaderOps, but
// optionally deferred until response time.
type RespHeaderOps struct {
- HeaderOps
+ *HeaderOps
Deferred bool `json:"deferred"`
}
@@ -51,7 +51,7 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhtt
return next.ServeHTTP(w, r)
}
-func apply(ops HeaderOps, hdr http.Header, repl caddy2.Replacer) {
+func apply(ops *HeaderOps, hdr http.Header, repl caddy2.Replacer) {
for fieldName, vals := range ops.Add {
fieldName = repl.ReplaceAll(fieldName, "")
for _, v := range vals {
@@ -75,7 +75,7 @@ func apply(ops HeaderOps, hdr http.Header, repl caddy2.Replacer) {
type responseWriterWrapper struct {
*caddyhttp.ResponseWriterWrapper
replacer caddy2.Replacer
- headerOps HeaderOps
+ headerOps *HeaderOps
wroteHeader bool
}