fixed wrong param type in http handler
This commit is contained in:
parent
f223bbec8f
commit
145642c6e9
13
web/http.go
13
web/http.go
@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.timovolkmann.de/gyrogpsc/core"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/template/html"
|
||||
@ -71,13 +72,14 @@ func allTrackingsHandler(s core.Service, c *core.Configuration) fiber.Handler {
|
||||
func startPipelineHandler(s core.Service, c *core.Configuration) fiber.Handler {
|
||||
return func(ctx *fiber.Ctx) error {
|
||||
var collecs []core.CollectorType
|
||||
ser := ctx.Params("serial", "true")
|
||||
ser := ctx.Query("serial", "true")
|
||||
if ser == "true" {
|
||||
collecs = append(collecs, core.SERIAL)
|
||||
} else if ser != "false" && ser != "" {
|
||||
collecs = append(collecs, core.CollectorType(ser)) // TODO: allow passing serial port as url parameter
|
||||
}
|
||||
tcp := ctx.Params("tcp", "true")
|
||||
tcp := ctx.Query("tcp", "true")
|
||||
logrus.Debugln("query values: serial/tcp", ser, tcp)
|
||||
if tcp == "true" {
|
||||
collecs = append(collecs, core.TCP)
|
||||
}
|
||||
@ -88,10 +90,13 @@ func startPipelineHandler(s core.Service, c *core.Configuration) fiber.Handler {
|
||||
}
|
||||
prepres := map[string]interface{}{}
|
||||
prepres["tracking_state"] = res
|
||||
//prepres["data"] = res
|
||||
prepres["data"] = collecs
|
||||
if err != nil {
|
||||
prepres["error"] = err.Error()
|
||||
|
||||
}
|
||||
if len(collecs) == 0 {
|
||||
e := errors.New("attention! no collectors running. start a new pipeline")
|
||||
prepres["error"] = e.Error()
|
||||
}
|
||||
err2 := ctx.JSON(prepres)
|
||||
if err2 != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user