Skip to content

Commit

Permalink
router を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
H1rono committed Jun 18, 2022
1 parent 3b46882 commit 95855a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 0 additions & 3 deletions router/getCode.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ func GetCodeHandler(c echo.Context) error {
if err != nil {
return echo.NewHTTPError(http.StatusNotFound, "Not Found")
}
if code == nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Internal Server Error")
}
return c.JSON(200, getCodeResponse{code.PlainCode, code.Stdin, code.Title, code.Options})
}
5 changes: 2 additions & 3 deletions router/postCode.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,20 @@ func PostCodeHandler(c echo.Context) error {

code := model.Code{
UserName: userName,
Hash: "",
PlainCode: data.PlainCode,
Stdin: data.Stdin,
Title: data.Title,
Options: data.Options,
}

err = model.AddCode(c.Request().Context(), &code)
hash, err := model.AddCode(c.Request().Context(), &code)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("%w", err))
}

res := postCodeResponse{
UserName: userName,
Hash: code.Hash,
Hash: hash,
}

return c.JSON(http.StatusOK, res)
Expand Down

0 comments on commit 95855a1

Please sign in to comment.