Bake output for metrics output.
(registry, accept_header, accept_encoding_header, params, disable_compression)
| 114 | |
| 115 | |
| 116 | def _bake_output(registry, accept_header, accept_encoding_header, params, disable_compression): |
| 117 | """Bake output for metrics output.""" |
| 118 | # Choose the correct plain text format of the output. |
| 119 | encoder, content_type = choose_encoder(accept_header) |
| 120 | if 'name[]' in params: |
| 121 | registry = registry.restricted_registry(params['name[]']) |
| 122 | output = encoder(registry) |
| 123 | headers = [('Content-Type', content_type)] |
| 124 | # If gzip encoding required, gzip the output. |
| 125 | if not disable_compression and gzip_accepted(accept_encoding_header): |
| 126 | output = gzip.compress(output) |
| 127 | headers.append(('Content-Encoding', 'gzip')) |
| 128 | return '200 OK', headers, output |
| 129 | |
| 130 | |
| 131 | def make_wsgi_app(registry: Collector = REGISTRY, disable_compression: bool = False) -> Callable: |
no test coverage detected