-
Notifications
You must be signed in to change notification settings - Fork 0
/
meta.go
46 lines (34 loc) · 1.31 KB
/
meta.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
// Package samplemeta implements sample type Meta which holds template metadata
package samplemeta
// Meta holds template metadata
type Meta struct {
Title string
error error
layout string
// Used in http test
contentType string
status int
}
// NewMeta returns new initialised Meta struct
func NewMeta(status int, ctype string) *Meta {
return &Meta{status: status, contentType: ctype, layout: "default"}
}
// SetTitle sets page title
func (m *Meta) SetTitle(name string) string { m.Title = name; return "" }
// SetLayout sets page layout
func (m *Meta) SetLayout(name string) string { m.layout = name; return "" }
// SetStatus sets response status
func (m *Meta) SetStatus(status int) string { m.status = status; return "" }
// SetContentType - set page content type
func (m *Meta) SetContentType(name string) string { m.contentType = name; return "" }
// Layout returns page layout
func (m Meta) Layout() string { return m.layout }
// SetError sets error by template engine
// Not for use in templates (see Raise)
func (m *Meta) SetError(e error) { m.error = e }
// Error returns page error
func (m Meta) Error() error { return m.error }
// ContentType returns page content type
func (m Meta) ContentType() string { return m.contentType }
// Status returns page status
func (m Meta) Status() int { return m.status }