-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
34 lines (28 loc) · 831 Bytes
/
types.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 main
import "time"
//IndexPage represents the content of the index page, available on "/"
//The index page shows a list of all books stored on db
type IndexPage struct {
AllBooks []Book
}
//BookPage represents the content of the book page, available on "/book.html"
//The book page shows info about a given book
type BookPage struct {
TargetBook Book
}
//Book represents a book object
type Book struct {
ID int
Name string
Author string
PublicationDate time.Time
Pages int
}
//PublicationDateStr returns a sanitized Publication Date in the format YYYY-MM-DD
func (b Book) PublicationDateStr() string {
return b.PublicationDate.Format("2006-01-02")
}
//ErrorPage represents shows an error message, available on "/book.html"
type ErrorPage struct {
ErrorMsg string
}