wip: call upload
This commit is contained in:
parent
8b5e38d08c
commit
b5c0781631
2 changed files with 45 additions and 0 deletions
44
pkg/gordio/server/calls.go
Normal file
44
pkg/gordio/server/calls.go
Normal file
|
@ -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"))
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ func (s *Server) setupRoutes() {
|
||||||
r.Use(render.SetContentType(render.ContentTypeJSON))
|
r.Use(render.SetContentType(render.ContentTypeJSON))
|
||||||
// public routes
|
// public routes
|
||||||
r.Post("/auth", s.routeAuth)
|
r.Post("/auth", s.routeAuth)
|
||||||
|
r.Post("/api/call-upload", s.routeCallUpload)
|
||||||
})
|
})
|
||||||
|
|
||||||
r.Group(func(r chi.Router) {
|
r.Group(func(r chi.Router) {
|
||||||
|
|
Loading…
Reference in a new issue