Skip to content

Commit

Permalink
add diff endpoint and fix version save
Browse files Browse the repository at this point in the history
  • Loading branch information
jfontan committed Jul 15, 2021
1 parent 16f2463 commit 9be5ee5
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (s *Server) routes() {
s.echo.Static("/thumbs", "./data/thumbs")
s.echo.Static("/css", "./server/assets/css")
s.echo.Static("/js", "./server/assets/js")
s.echo.File("/diff", "./server/assets/diff.html")
}

func (s *Server) indexHandler(c echo.Context) error {
Expand All @@ -115,7 +116,6 @@ func (s *Server) indexHandler(c echo.Context) error {
}
}

println(page, len(effects), perPage)
d := galleryData{
Effects: effects,
IsNext: len(effects) == perPage,
Expand Down Expand Up @@ -177,11 +177,11 @@ func (s *Server) itemHandler(c echo.Context) error {
}

type saveQuery struct {
Code string `json:"Code"`
Image string `json:"Image"`
User string `json:"User"`
CodeID string `json:"CodeID"`
Parent string `json:"Parent"`
Code string `json:"code"`
Image string `json:"image"`
User string `json:"user"`
CodeID string `json:"code_id"`
Parent string `json:"parent"`
}

func (s *Server) saveHandler(c echo.Context) error {
Expand Down Expand Up @@ -229,7 +229,12 @@ func (s *Server) saveHandler(c echo.Context) error {
return c.String(http.StatusInternalServerError, "")
}
} else {
id, err = strconv.Atoi(save.CodeID)
parts := strings.Split(save.CodeID, ".")
if len(parts) < 1 {
c.Logger().Errorf("malformed code id: %s", err.Error())
return c.String(http.StatusBadRequest, "")
}
id, err = strconv.Atoi(parts[0])
if err != nil {
c.Logger().Errorf("malformed code id: %s", err.Error())
return c.String(http.StatusBadRequest, "")
Expand Down

0 comments on commit 9be5ee5

Please sign in to comment.