-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.go
More file actions
72 lines (62 loc) · 2.05 KB
/
routes.go
File metadata and controls
72 lines (62 loc) · 2.05 KB
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
package main
import (
"github.com/labstack/echo"
"net/http"
"notes/usecase"
)
func execute(e *echo.Echo) {
// index
e.GET("/", func(c echo.Context) error {
request := c.Request()
base := "https://" + request.Host
path := request.RequestURI
data := usecase.PoiData{
HeaderInfo: usecase.Header{
Title: "/tmp/notes | ウェブに残せるちょっとしたメモ帳",
Keywords: "ポイメモ,/tmp/notes,一週間,期間限定,メモ,ノート,memo,note,7日間,OSS,オープンソース,ポイ,簡易メモ帳,共有,シェア",
Description: "/tmp/notes(ポイメモ)はしっかり記録するほどでもない「ちょっとだけメモを取っておきたい」をカタチにする、ウェブ投稿型のメモ帳サービスです。メモの閲覧可能期間は1週間。投稿から1週間が経過すると自動的に表示されなくなります。",
},
Page: "index",
BaseURL: base,
URL: base + path,
}
return c.Render(http.StatusOK, "layout", data)
})
// Show Poi index page.
e.GET("/poi/", func(c echo.Context) error {
data := usecase.GetPoiIndex(c)
return c.Render(http.StatusOK, "layout", data)
})
// Show Poi detail page
e.GET("/poi/:id", func(c echo.Context) error {
data := usecase.GetPoiDetail(c)
if data.Notes == nil {
return c.Render(http.StatusNotFound, "404", nil)
}
return c.Render(http.StatusOK, "layout", data)
})
// Post Poi data
e.POST("/poi/", func(c echo.Context) error {
var id string
note := usecase.PostPoiDetail(c)
if note != nil {
id = note.ID
}
return c.Redirect(http.StatusMovedPermanently, "/poi/"+id)
})
// tag list
e.GET("/tag/", func(c echo.Context) error {
data := usecase.GetTagIndex(c)
return c.Render(http.StatusOK, "layout", data)
})
//
e.POST("/tag/", func(c echo.Context) error {
tag := usecase.PostTagDetail(c)
return c.Redirect(http.StatusMovedPermanently, "/tag/"+tag)
})
// tag detail
e.GET("/tag/:id", func(c echo.Context) error {
data := usecase.GetTagDetail(c)
return c.Render(http.StatusOK, "layout", data)
})
}