You've already forked reloading-manager
fix tpyo (#8)
Reviewed-on: Siteworxpro/reloading-manager#8 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
This commit was merged in pull request #8.
This commit is contained in:
@@ -21,12 +21,15 @@ type BulletResponse struct {
|
||||
|
||||
func Photo(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
id := c.Param("id")
|
||||
uid := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if uid == nil {
|
||||
return nil
|
||||
uid, err := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID format")
|
||||
}
|
||||
|
||||
byId, err := db.Bullets.GetBulletById(context.Background(), *uid)
|
||||
@@ -48,15 +51,18 @@ func Photo(c echo.Context) error {
|
||||
|
||||
func Delete(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
id := c.Param("id")
|
||||
uid := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if uid == nil {
|
||||
return nil
|
||||
uid, err := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if err != nil || uid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID format")
|
||||
}
|
||||
|
||||
err := db.Bullets.DeleteBullet(context.Background(), *uid)
|
||||
err = db.Bullets.DeleteBullet(context.Background(), *uid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -66,12 +72,14 @@ func Delete(c echo.Context) error {
|
||||
|
||||
func Put(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
id := c.Param("id")
|
||||
uid := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if uid == nil {
|
||||
return nil
|
||||
uid, err := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if err != nil || uid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID format")
|
||||
}
|
||||
|
||||
byId, err := db.Bullets.GetBulletById(context.Background(), *uid)
|
||||
@@ -101,9 +109,9 @@ func Put(c echo.Context) error {
|
||||
weight, _ := strconv.ParseInt(c.FormValue("weight"), 10, 32)
|
||||
diameter, _ := strconv.ParseInt(c.FormValue("diameter"), 10, 32)
|
||||
manufacturerId := c.FormValue("manufacturer_id")
|
||||
manufacturerUid := handlers.ParseUuidOrBadRequest(c, manufacturerId)
|
||||
if manufacturerUid == nil {
|
||||
return nil
|
||||
manufacturerUid, err := handlers.ParseUuidOrBadRequest(c, manufacturerId)
|
||||
if err == nil || manufacturerUid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID format")
|
||||
}
|
||||
|
||||
name := c.FormValue("name")
|
||||
@@ -147,13 +155,15 @@ func Put(c echo.Context) error {
|
||||
|
||||
func Get(c echo.Context) error {
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
if c.Param("id") != "" {
|
||||
id := c.Param("id")
|
||||
uid := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if uid == nil {
|
||||
return nil
|
||||
uid, err := handlers.ParseUuidOrBadRequest(c, id)
|
||||
if err != nil || uid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID format")
|
||||
}
|
||||
|
||||
byId, err := db.Bullets.GetBulletById(context.Background(), *uid)
|
||||
@@ -210,7 +220,6 @@ func Get(c echo.Context) error {
|
||||
}
|
||||
|
||||
func Post(c echo.Context) error {
|
||||
|
||||
file, err := c.FormFile("photo")
|
||||
if err != nil {
|
||||
c.Logger().Error(err)
|
||||
@@ -245,11 +254,13 @@ func Post(c echo.Context) error {
|
||||
}
|
||||
|
||||
db := c.(*database.CustomContext).Db
|
||||
defer db.Db.Close(context.Background())
|
||||
defer func() {
|
||||
_ = db.Db.Close(context.Background())
|
||||
}()
|
||||
|
||||
manufacturerUid := handlers.ParseUuidOrBadRequest(c, manufacturerId)
|
||||
if manufacturerUid == nil {
|
||||
return nil
|
||||
manufacturerUid, err := handlers.ParseUuidOrBadRequest(c, manufacturerId)
|
||||
if err != nil || manufacturerUid == nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid UUID format")
|
||||
}
|
||||
|
||||
manufacturer, err := db.Manufacturer.GetById(context.Background(), *manufacturerUid)
|
||||
|
||||
Reference in New Issue
Block a user