escapingFor returns the escaping term for the Accept clause that matched f.
(ac goautoneg.Accept, f Format)
| 159 | |
| 160 | // escapingFor returns the escaping term for the Accept clause that matched f. |
| 161 | func escapingFor(ac goautoneg.Accept, f Format) Format { |
| 162 | switch p := ac.Params[model.EscapingKey]; p { |
| 163 | case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues: |
| 164 | // An explicit request always wins, also for OpenMetrics 2.0. |
| 165 | return Format("; escaping=" + p) |
| 166 | } |
| 167 | if f.FormatType() == TypeOpenMetrics && isOpenMetrics20Version(f.Version()) { |
| 168 | // OpenMetrics 2.0 is UTF-8 native, so asking for it implies UTF-8 name support. |
| 169 | return Format("; escaping=" + model.AllowUTF8) |
| 170 | } |
| 171 | return Format("; escaping=" + model.NameEscapingScheme.String()) |
| 172 | } |
| 173 | |
| 174 | // matchFormat checks if a parsed accept clause matches a given Format. |
| 175 | func matchFormat(ac goautoneg.Accept, f Format) bool { |
no test coverage detected