Skip to content

Commit

Permalink
add pkgx gin
Browse files Browse the repository at this point in the history
  • Loading branch information
Yichuan Deng committed May 23, 2021
1 parent 2e7c309 commit 9118192
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 66 deletions.
44 changes: 44 additions & 0 deletions controller/api/v1/user.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package api

import (
"context"
"fmt"

"github.com/colinrs/ffly-plus/internal"
"github.com/colinrs/ffly-plus/internal/code"
"github.com/colinrs/ffly-plus/service"

serverGin "github.com/colinrs/pkgx/server/gin"
"github.com/gin-gonic/gin"
)

// UserController ...
type UserController struct {
}

// GetUser ...
// @Summary GetUser
// @Produce json
Expand Down Expand Up @@ -105,3 +113,39 @@ func UserLogin(c *gin.Context) {
internal.APIResponse(c, err, token)

}

// UserHelloResponse ...
type UserHelloResponse struct {
Message string `json:"message"`
}

// Output ...
func (userHelloResponse UserHelloResponse) Output() {
fmt.Print("run userHelloResponse Output\n")
}

// UserHelloRequest ...
type UserHelloRequest struct {
UserMessage string `form:"user_message" json:"user_message"`
Age int `form:"age" json:"age" binding:"ccless=10"`
}

// Validator ...
func (userHelloRequest UserHelloRequest) Validator(ctx context.Context) error {
fmt.Print("run userHelloRequest Validator\n")
return nil
}

// UserHello ...
func UserHello(ctx context.Context, request *UserHelloRequest) (UserHelloResponse, error) {
res := UserHelloResponse{}
res.Message = request.UserMessage
return res, nil
}

// Init ...
func (uc *UserController) Init(engine *serverGin.Engine) error {
fmt.Print("run UserController Init\n")
engine.GET("/user_hello", UserHello)
return nil
}
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ require (
github.com/alibaba/sentinel-golang v0.6.1
github.com/arl/statsviz v0.1.1
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668 // indirect
github.com/colinrs/pkgx v0.0.0-20191114035542-ebceb52a92ee
github.com/colinrs/pkgx v1.1.0
github.com/colinrs/pkgx/server/gin v0.0.0-20210523102601-7e9d7838ef60
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fsnotify/fsnotify v1.4.7
github.com/gin-contrib/cache v1.1.0
github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.6.3
github.com/golang/protobuf v1.4.0
github.com/gin-gonic/gin v1.7.2
github.com/golang/protobuf v1.4.3
github.com/pkg/errors v0.9.1
github.com/spf13/viper v1.7.1
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14
github.com/swaggo/gin-swagger v1.2.0
github.com/swaggo/swag v1.6.8
github.com/urfave/cli v1.22.4
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20201021035429-f5854403a974
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102
golang.org/x/tools v0.0.0-20201105001634-bc3cf281b174 // indirect
google.golang.org/grpc v1.27.0
gorm.io/driver/mysql v1.0.2
Expand Down
Loading

0 comments on commit 9118192

Please sign in to comment.