Skip to content
Snippets Groups Projects
Verified Commit 89fa7949 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

fix: try to get showId from the body as JSON

parent 196c9694
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
package v1
import (
"github.com/gin-gonic/gin/binding"
"net/http"
"strconv"
......@@ -25,18 +26,27 @@ import (
"gitlab.servus.at/autoradio/tank/store"
)
type ShowId struct {
ShowId uint64 `json:"showId"`
}
func idFromString(s string) (uint64, error) {
return strconv.ParseUint(s, 10, 64)
}
func getShowID(c *gin.Context) (uint64, error) {
// TODO: get rid of this when we remove the nested routes
showID := c.Param("show-id")
if showID == "" {
showID = c.Query("showId")
}
return idFromString(showID)
//// TODO: get rid of this when we remove the nested routes
//showID := c.Param("show-id")
//if showID == "" {
// showID = c.Query("showId")
//}
// read the showId as JSON from the body and allow the body to be read again
var showId ShowId
if err := c.ShouldBindBodyWith(&showId, binding.JSON); err != nil {
return 0, err
}
return showId.ShowId, nil
}
func statusCodeFromError(err error) (code int, response ErrorResponse) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment