You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
708 B
33 lines
708 B
package main |
|
|
|
import ( |
|
"github.com/gin-gonic/gin" |
|
user "github.com/mogfee/protoc-gen-kit/proto/v1" |
|
"github.com/mogfee/protoc-gen-kit/response" |
|
"github.com/mogfee/protoc-gen-kit/service" |
|
) |
|
|
|
func main() { |
|
app := gin.Default() |
|
app.GET("/", func(c *gin.Context) { |
|
resp := response.New(c) |
|
post := user.LoginRequest{} |
|
if err := resp.BindQuery(&post); err != nil { |
|
resp.Error(err) |
|
return |
|
} |
|
c.JSON(200, post) |
|
}) |
|
app.POST("/", func(c *gin.Context) { |
|
resp := response.New(c) |
|
post := user.LoginRequest{} |
|
if err := resp.BindJSON(&post); err != nil { |
|
resp.Error(err) |
|
return |
|
} |
|
c.JSON(200, post) |
|
}) |
|
srv := service.UserService{} |
|
user.NewGin(app, &srv) |
|
app.Run("localhost:8888") |
|
}
|
|
|