-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia_range.go
34 lines (30 loc) · 979 Bytes
/
media_range.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package openapi
import (
"mime"
)
// MediaRange represents a media type or media type range. It is the key type in the Content map.
// See [RFC7231 Appendix D], and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*
//
// Some examples of possible media type definitions:
//
// text/plain; charset=utf-8
// application/json
// application/vnd.github+json
// application/vnd.github.v3+json
// application/vnd.github.v3.raw+json
// application/vnd.github.v3.text+json
// application/vnd.github.v3.html+json
// application/vnd.github.v3.full+json
// application/vnd.github.v3.diff
// application/vnd.github.v3.patch
//
// [RFC7231]: https://datatracker.ietf.org/doc/html/rfc7231#appendix-D
type MediaRange string
const (
MediaRangeJSON = "application/json"
MediaRangeHTML = "text/html"
)
func (mr MediaRange) Validate() error {
_, _, err := mime.ParseMediaType(string(mr))
return err
}