diff --git a/pkg/gordio/server/calls.go b/pkg/gordio/server/calls.go new file mode 100644 index 0000000..51fe9fc --- /dev/null +++ b/pkg/gordio/server/calls.go @@ -0,0 +1,44 @@ +package server + +import ( + "fmt" + "net/http" + "time" + + "github.com/go-chi/render" +) + +type callUploadRequest struct { + Audio []byte `form:"audio"` + AudioName string `form:"audioName"` + AudioType time.Time `form:"audioType"` + DateTime string `form:"dateTime"` + Frequencies []int `form:"frequencies"` + Frequency int `form:"frequency"` + Key string `form:"key"` + Patches []string `form:"patches"` + Source string `form:"source"` + Sources []string `form:"sources"` + System string `form:"system"` + SystemLabel string `form:"systemLabel"` + Talkgroup int `form:"talkgroup"` + TalkgroupGroup string `form:"talkgroupGroup"` + TalkgroupLabel string `form:"talkgroupLabel"` + TalkgroupTag string `form:"talkgroupTag"` +} + +func (car *callUploadRequest) Bind(r *http.Request) error { + return nil +} + +func (s *Server) routeCallUpload(w http.ResponseWriter, r *http.Request) { + callUpload := new(callUploadRequest) + err := render.Bind(r, callUpload) + if err != nil { + http.Error(w, "cannot bind upload", 500) + return + } + + fmt.Printf("%#v\n", callUpload) + w.Write([]byte("yay")) +} diff --git a/pkg/gordio/server/routes.go b/pkg/gordio/server/routes.go index e6a229d..1148652 100644 --- a/pkg/gordio/server/routes.go +++ b/pkg/gordio/server/routes.go @@ -27,6 +27,7 @@ func (s *Server) setupRoutes() { r.Use(render.SetContentType(render.ContentTypeJSON)) // public routes r.Post("/auth", s.routeAuth) + r.Post("/api/call-upload", s.routeCallUpload) }) r.Group(func(r chi.Router) {