Add attribute list call

This commit is contained in:
Nise Void 2018-05-28 14:41:13 +02:00
parent df44cd0038
commit 85165d5c74
Signed by: NiseVoid
GPG Key ID: FBA14AC83EA602F3
2 changed files with 12 additions and 38 deletions

View File

@ -74,24 +74,6 @@
"null": false,
"size": 8
},
{
"name": "p_gem_1",
"type": "double precision",
"null": false,
"size": 8
},
{
"name": "p_gem_2",
"type": "double precision",
"null": false,
"size": 8
},
{
"name": "p_gem_3",
"type": "double precision",
"null": false,
"size": 8
},
{
"name": "p_max_1",
"type": "double precision",
@ -110,24 +92,6 @@
"null": false,
"size": 8
},
{
"name": "s_gem_1",
"type": "double precision",
"null": false,
"size": 8
},
{
"name": "s_gem_2",
"type": "double precision",
"null": false,
"size": 8
},
{
"name": "s_gem_3",
"type": "double precision",
"null": false,
"size": 8
},
{
"name": "s_max_1",
"type": "double precision",

View File

@ -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`))