Skip to content

Commit 0e7c817

Browse files
committed
api/types: add MediaType pseudo-type, and touch-up docs
Add a `MediaType` pseudo-type to help discoverability of mediatypes we use, and slightly touch up the documentation. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 65d8d0b commit 0e7c817

2 files changed

Lines changed: 48 additions & 24 deletions

File tree

api/types/types.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
package types
22

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+
311
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"
614

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"
921

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"
1224

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"
1527

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"
1830

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"
2133
)

vendor/github.com/moby/moby/api/types/types.go

Lines changed: 24 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)