Provision provisions enc.
(ctx caddy.Context)
| 67 | |
| 68 | // Provision provisions enc. |
| 69 | func (enc *Encode) Provision(ctx caddy.Context) error { |
| 70 | mods, err := ctx.LoadModule(enc, "EncodingsRaw") |
| 71 | if err != nil { |
| 72 | return fmt.Errorf("loading encoder modules: %v", err) |
| 73 | } |
| 74 | for modName, modIface := range mods.(map[string]any) { |
| 75 | err = enc.addEncoding(modIface.(Encoding)) |
| 76 | if err != nil { |
| 77 | return fmt.Errorf("adding encoding %s: %v", modName, err) |
| 78 | } |
| 79 | } |
| 80 | if enc.MinLength == 0 { |
| 81 | enc.MinLength = defaultMinLength |
| 82 | } |
| 83 | |
| 84 | if enc.Matcher == nil { |
| 85 | // common text-based content types |
| 86 | // list based on https://developers.cloudflare.com/speed/optimization/content/brotli/content-compression/#compression-between-cloudflare-and-website-visitors |
| 87 | enc.Matcher = &caddyhttp.ResponseMatcher{ |
| 88 | Headers: http.Header{ |
| 89 | "Content-Type": []string{ |
| 90 | "application/atom+xml*", |
| 91 | "application/eot*", |
| 92 | "application/font*", |
| 93 | "application/geo+json*", |
| 94 | "application/graphql+json*", |
| 95 | "application/graphql-response+json*", |
| 96 | "application/javascript*", |
| 97 | "application/json*", |
| 98 | "application/ld+json*", |
| 99 | "application/manifest+json*", |
| 100 | "application/opentype*", |
| 101 | "application/otf*", |
| 102 | "application/rss+xml*", |
| 103 | "application/truetype*", |
| 104 | "application/ttf*", |
| 105 | "application/vnd.api+json*", |
| 106 | "application/vnd.ms-fontobject*", |
| 107 | "application/wasm*", |
| 108 | "application/x-httpd-cgi*", |
| 109 | "application/x-javascript*", |
| 110 | "application/x-opentype*", |
| 111 | "application/x-otf*", |
| 112 | "application/x-perl*", |
| 113 | "application/x-protobuf*", |
| 114 | "application/x-ttf*", |
| 115 | "application/xhtml+xml*", |
| 116 | "application/xml*", |
| 117 | "font/ttf*", |
| 118 | "font/otf*", |
| 119 | "image/svg+xml*", |
| 120 | "image/vnd.microsoft.icon*", |
| 121 | "image/x-icon*", |
| 122 | "multipart/bag*", |
| 123 | "multipart/mixed*", |
| 124 | "text/*", |
| 125 | }, |
| 126 | }, |
nothing calls this directly
no test coverage detected