-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtype.go
More file actions
36 lines (30 loc) · 840 Bytes
/
Copy pathtype.go
File metadata and controls
36 lines (30 loc) · 840 Bytes
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
35
36
package resource
import (
"mime"
"net/url"
)
// PageType encapsulates the various descriptions of the kind of page / content
type PageType struct {
ContType string `json:"contentType"`
MedType string `json:"mediaType"`
MedTypeParams MediaTypeParams `json:"mediaTypeParams"`
}
func NewPageType(url *url.URL, contentType string) (Type, error) {
result := new(PageType)
result.ContType = contentType
var mediaTypeError error
result.MedType, result.MedTypeParams, mediaTypeError = mime.ParseMediaType(contentType)
if mediaTypeError != nil {
return result, mediaTypeError
}
return result, nil
}
func (t PageType) ContentType() string {
return t.ContType
}
func (t PageType) MediaType() string {
return t.MedType
}
func (t PageType) MediaTypeParams() MediaTypeParams {
return t.MedTypeParams
}