Add attribute list call
This commit is contained in:
parent
df44cd0038
commit
85165d5c74
2 changed files with 12 additions and 38 deletions
|
@ -28,10 +28,14 @@ func main() {
|
|||
e.HideBanner = true
|
||||
e.Use(recoverMiddleware)
|
||||
|
||||
e.GET(`/count`, count)
|
||||
pq := e.Group(`/pq`)
|
||||
pq.GET(`/count`, count)
|
||||
pq.GET(`/list`, listAttr)
|
||||
|
||||
for _, v := range app.GetAttributes() {
|
||||
e.GET(`/`+strings.ToLower(v.Name)+`/:date`, getAttr(v.Index))
|
||||
pq.GET(`/`+strings.ToLower(v.Name)+`/:date`, getAttr(v.Index))
|
||||
|
||||
attrs = append(attrs, strings.ToLower(v.Name))
|
||||
}
|
||||
|
||||
panic(e.Start(`localhost:33333`))
|
||||
|
@ -41,6 +45,12 @@ func count(c echo.Context) error {
|
|||
return c.JSON(200, app.Count())
|
||||
}
|
||||
|
||||
var attrs []string
|
||||
|
||||
func listAttr(c echo.Context) error {
|
||||
return c.JSON(200, attrs)
|
||||
}
|
||||
|
||||
func getAttr(index int) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
date, err := time.Parse(time.RFC3339, c.Param(`date`))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue