-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpageinfo.go
82 lines (66 loc) · 1.76 KB
/
pageinfo.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package web
import (
"net/http"
"time"
)
// ChangeFrequency tells how frequently the page is likely to change
type ChangeFrequency int
const (
ChangeFrequencyUnknown ChangeFrequency = iota
ChangeFrequencyNever
ChangeFrequencyAlways
ChangeFrequencyHourly
ChangeFrequencyDaily
ChangeFrequencyWeekly
ChangeFrequencyMonthly
ChangeFrequencyYearly
)
func (f ChangeFrequency) String() string {
s := []string{"", "never", "always", "hourly", "weekly", "monthly", "yearly"}
n := int(f)
if f > ChangeFrequencyUnknown &&
n < len(s) {
return s[n]
}
return ""
}
// Router can check for the existance of the requested resource
type RouterPageInfo interface {
PageInfo(*http.Request) (interface{}, bool)
}
// PageInfo can tell how frequencly the page is likely to change
type PageInfoChangeFrequency interface {
ChangeFrequency() string
}
// PageInfo can tell what Path was requested
type PageInfoLocation interface {
Location() string
}
// PageInfo can tell the recommended Path to access this resource
type PageInfoCanonical interface {
Canonical() string
}
// PageInfo can tell the relevance of this resource
type PageInfoPriority interface {
Priority() float32
}
// PageInfo can tell when the package was last modified
type PageInfoLastModified interface {
LastModified() time.Time
}
// PageInfo can tell the mime-types supported by the resource
type PageInfoMimeType interface {
MimeType() []string
}
// PageInfo can tell the languages supported by the resource
type PageInfoLanguage interface {
Language() []string
}
// PageInfo can tell the supported methods supported by the resource
type PageInfoMethods interface {
Method() []string
}
// PageInfo can tell what handler to use to request the resource
type PageInfoHandler interface {
Handler() http.Handler
}