Skip to content

Commit

Permalink
fix linter errors and update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
yakuter committed Sep 5, 2021
1 parent 6b25902 commit e7376b1
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 171 deletions.
5 changes: 0 additions & 5 deletions controller/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ import (

var (
userLoginErr = "User email or master password is wrong."
userVerifyErr = "Please verify your email first."
invalidUser = "Invalid user"
validToken = "Token is valid"
invalidToken = "Token is expired or not valid!"
noToken = "Token could not found! "
tokenCreateErr = "Token could not be created"
signupSuccess = "User created successfully"
verifySuccess = "Email verified successfully"
)

// Signup Controller
Expand Down
14 changes: 11 additions & 3 deletions controller/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ func (base *Controller) GetPosts(c *gin.Context) {
func (base *Controller) CreatePost(c *gin.Context) {
post := new(model.Post)

c.ShouldBindJSON(&post)
err := c.ShouldBindJSON(&post)
if err != nil {
c.AbortWithStatus(400)
return
}

post, err := service.SavePost(base.DB, post)
post, err = service.SavePost(base.DB, post)
if err != nil {
c.AbortWithStatus(404)
return
Expand Down Expand Up @@ -113,7 +117,11 @@ func (base *Controller) UpdatePost(c *gin.Context) {
return
}

c.ShouldBindJSON(&post)
err = c.ShouldBindJSON(&post)
if err != nil {
c.AbortWithStatus(400)
return
}

post, err = service.SavePost(base.DB, post)
if err != nil {
Expand Down
13 changes: 4 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ module github.com/yakuter/ugin
go 1.15

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/didip/tollbooth v4.0.2+incompatible
github.com/gin-contrib/gzip v0.0.3
github.com/gin-gonic/gin v1.6.3
Expand All @@ -17,13 +16,9 @@ require (
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.6.1
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 // indirect
github.com/swaggo/gin-swagger v1.3.0 // indirect
github.com/swaggo/swag v1.7.0 // indirect
github.com/swaggo/gin-swagger v1.3.0
github.com/swaggo/swag v1.7.0
github.com/ugorji/go v1.2.4 // indirect
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
Expand Down
38 changes: 17 additions & 21 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ func main() {
r := router.Setup(db)

log.Printf("Server is starting at 127.0.0.1:%s", config.Server.Port)
r.Run("127.0.0.1:" + config.Server.Port)
log.Fatal(r.Run("127.0.0.1:" + config.Server.Port))
}
80 changes: 0 additions & 80 deletions main_test.go

This file was deleted.

1 change: 0 additions & 1 deletion pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

var (
validToken = "Token is valid"
invalidToken = "Token is expired or not valid!"
noToken = "Token could not found! "
)
Expand Down
2 changes: 1 addition & 1 deletion service/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TokenValid(bearerToken string) (*jwt.Token, error) {
}
return nil, err
}
if _, ok := token.Claims.(jwt.Claims); !ok && !token.Valid {
if !token.Valid {
return nil, fmt.Errorf("Unauthorized")
}
return token, nil
Expand Down
50 changes: 0 additions & 50 deletions service/helper_test.go

This file was deleted.

0 comments on commit e7376b1

Please sign in to comment.