Add a `MediaType` pseudo-type to help discoverability of mediatypes
we use, and slightly touch up the documentation.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -1,21 +1,33 @@ |
| 1 | 1 |
package types |
| 2 | 2 |
|
| 3 |
+// MediaType represents an HTTP media type (MIME type) used in API |
|
| 4 |
+// Content-Type and Accept headers. |
|
| 5 |
+// |
|
| 6 |
+// In addition to standard media types (for example, "application/json"), |
|
| 7 |
+// this package defines vendor-specific vendor media types for streaming |
|
| 8 |
+// endpoints, such as raw TTY streams and multiplexed stdout/stderr streams. |
|
| 9 |
+type MediaType = string |
|
| 10 |
+ |
|
| 3 | 11 |
const ( |
| 4 |
- // MediaTypeRawStream is vendor specific MIME-Type set for raw TTY streams. |
|
| 5 |
- MediaTypeRawStream = "application/vnd.docker.raw-stream" |
|
| 12 |
+ // MediaTypeRawStream is a vendor-specific media type for raw TTY streams. |
|
| 13 |
+ MediaTypeRawStream MediaType = "application/vnd.docker.raw-stream" |
|
| 6 | 14 |
|
| 7 |
- // MediaTypeMultiplexedStream is vendor specific MIME-Type set for stdin/stdout/stderr multiplexed streams. |
|
| 8 |
- MediaTypeMultiplexedStream = "application/vnd.docker.multiplexed-stream" |
|
| 15 |
+ // MediaTypeMultiplexedStream is a vendor-specific media type for streams |
|
| 16 |
+ // where stdin, stdout, and stderr are multiplexed into a single byte stream. |
|
| 17 |
+ // |
|
| 18 |
+ // Use stdcopy.StdCopy (https://pkg.go.dev/github.com/moby/moby/api/pkg/stdcopy) |
|
| 19 |
+ // to demultiplex the stream. |
|
| 20 |
+ MediaTypeMultiplexedStream MediaType = "application/vnd.docker.multiplexed-stream" |
|
| 9 | 21 |
|
| 10 |
- // MediaTypeJSON is the MIME-Type for JSON objects. |
|
| 11 |
- MediaTypeJSON = "application/json" |
|
| 22 |
+ // MediaTypeJSON is the media type for JSON objects. |
|
| 23 |
+ MediaTypeJSON MediaType = "application/json" |
|
| 12 | 24 |
|
| 13 |
- // MediaTypeNDJSON is the MIME-Type for Newline Delimited JSON objects streams (https://github.com/ndjson/ndjson-spec). |
|
| 14 |
- MediaTypeNDJSON = "application/x-ndjson" |
|
| 25 |
+ // MediaTypeNDJSON is the media type for newline-delimited JSON streams (https://github.com/ndjson/ndjson-spec). |
|
| 26 |
+ MediaTypeNDJSON MediaType = "application/x-ndjson" |
|
| 15 | 27 |
|
| 16 |
- // MediaTypeJSONLines is the MIME-Type for JSONLines objects streams (https://jsonlines.org/). |
|
| 17 |
- MediaTypeJSONLines = "application/jsonl" |
|
| 28 |
+ // MediaTypeJSONLines is the media type for JSON Lines streams (https://jsonlines.org/). |
|
| 29 |
+ MediaTypeJSONLines MediaType = "application/jsonl" |
|
| 18 | 30 |
|
| 19 |
- // MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464). |
|
| 20 |
- MediaTypeJSONSequence = "application/json-seq" |
|
| 31 |
+ // MediaTypeJSONSequence is the media type for JSON text sequences (RFC 7464). |
|
| 32 |
+ MediaTypeJSONSequence MediaType = "application/json-seq" |
|
| 21 | 33 |
) |
| ... | ... |
@@ -1,21 +1,33 @@ |
| 1 | 1 |
package types |
| 2 | 2 |
|
| 3 |
+// MediaType represents an HTTP media type (MIME type) used in API |
|
| 4 |
+// Content-Type and Accept headers. |
|
| 5 |
+// |
|
| 6 |
+// In addition to standard media types (for example, "application/json"), |
|
| 7 |
+// this package defines vendor-specific vendor media types for streaming |
|
| 8 |
+// endpoints, such as raw TTY streams and multiplexed stdout/stderr streams. |
|
| 9 |
+type MediaType = string |
|
| 10 |
+ |
|
| 3 | 11 |
const ( |
| 4 |
- // MediaTypeRawStream is vendor specific MIME-Type set for raw TTY streams. |
|
| 5 |
- MediaTypeRawStream = "application/vnd.docker.raw-stream" |
|
| 12 |
+ // MediaTypeRawStream is a vendor-specific media type for raw TTY streams. |
|
| 13 |
+ MediaTypeRawStream MediaType = "application/vnd.docker.raw-stream" |
|
| 6 | 14 |
|
| 7 |
- // MediaTypeMultiplexedStream is vendor specific MIME-Type set for stdin/stdout/stderr multiplexed streams. |
|
| 8 |
- MediaTypeMultiplexedStream = "application/vnd.docker.multiplexed-stream" |
|
| 15 |
+ // MediaTypeMultiplexedStream is a vendor-specific media type for streams |
|
| 16 |
+ // where stdin, stdout, and stderr are multiplexed into a single byte stream. |
|
| 17 |
+ // |
|
| 18 |
+ // Use stdcopy.StdCopy (https://pkg.go.dev/github.com/moby/moby/api/pkg/stdcopy) |
|
| 19 |
+ // to demultiplex the stream. |
|
| 20 |
+ MediaTypeMultiplexedStream MediaType = "application/vnd.docker.multiplexed-stream" |
|
| 9 | 21 |
|
| 10 |
- // MediaTypeJSON is the MIME-Type for JSON objects. |
|
| 11 |
- MediaTypeJSON = "application/json" |
|
| 22 |
+ // MediaTypeJSON is the media type for JSON objects. |
|
| 23 |
+ MediaTypeJSON MediaType = "application/json" |
|
| 12 | 24 |
|
| 13 |
- // MediaTypeNDJSON is the MIME-Type for Newline Delimited JSON objects streams (https://github.com/ndjson/ndjson-spec). |
|
| 14 |
- MediaTypeNDJSON = "application/x-ndjson" |
|
| 25 |
+ // MediaTypeNDJSON is the media type for newline-delimited JSON streams (https://github.com/ndjson/ndjson-spec). |
|
| 26 |
+ MediaTypeNDJSON MediaType = "application/x-ndjson" |
|
| 15 | 27 |
|
| 16 |
- // MediaTypeJSONLines is the MIME-Type for JSONLines objects streams (https://jsonlines.org/). |
|
| 17 |
- MediaTypeJSONLines = "application/jsonl" |
|
| 28 |
+ // MediaTypeJSONLines is the media type for JSON Lines streams (https://jsonlines.org/). |
|
| 29 |
+ MediaTypeJSONLines MediaType = "application/jsonl" |
|
| 18 | 30 |
|
| 19 |
- // MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464). |
|
| 20 |
- MediaTypeJSONSequence = "application/json-seq" |
|
| 31 |
+ // MediaTypeJSONSequence is the media type for JSON text sequences (RFC 7464). |
|
| 32 |
+ MediaTypeJSONSequence MediaType = "application/json-seq" |
|
| 21 | 33 |
) |