diff --git a/mail/index.gohtml b/assets/hackernews_template.gohtml
similarity index 100%
rename from mail/index.gohtml
rename to assets/hackernews_template.gohtml
diff --git a/db/db.go b/db/db.go
index 268a113..7e3508d 100644
--- a/db/db.go
+++ b/db/db.go
@@ -25,11 +25,7 @@ type News struct {
Author string `json:"by"`
Url string `json:"url"`
Score int `json:"score"`
- Parent int `json:"parent"`
- Comments int `json:"descendants"`
Category string `json:"type"`
- Delete bool `json:"delete"`
- Dead bool `json:"dead"`
}
type DynamoDBDescribeTableAPI interface {
diff --git a/hackernews/hackernews.go b/hackernews/hackernews.go
index cf30497..a42540d 100644
--- a/hackernews/hackernews.go
+++ b/hackernews/hackernews.go
@@ -10,6 +10,14 @@ import (
"strings"
)
+func HackernewsTable() string {
+ return "hacker_news_table"
+}
+
+func HackernewsTemplate() string {
+ return "hackernews_template"
+}
+
func GetTopNewsIds(url string) (response []string) {
fmt.Println("Retrieving news...")
diff --git a/handler/handler.go b/handler/handler.go
index d9f7886..c9345bb 100644
--- a/handler/handler.go
+++ b/handler/handler.go
@@ -22,7 +22,8 @@ func Handler(ctx context.Context) (string, error) {
fetchSize, _ := strconv.Atoi(os.Getenv("FETCH_SIZE"))
var newsBatch []db.News
- table := "news_table"
+ table := hackernews.HackernewsTable()
+ htmlTemplate := hackernews.HackernewsTable()
cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
@@ -64,7 +65,7 @@ func Handler(ctx context.Context) (string, error) {
todayNews, _ := db.ReadTodayNews(newsTable, int(timeStart.Unix()), int(timeEnd.Unix()))
- t, err := template.ParseFiles("mail/index.gohtml")
+ t, err := template.ParseFiles(fmt.Sprintf("assets/%v.gohtml", htmlTemplate))
if err != nil {
log.Fatalln(err)
}