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.
 
 

35 lines
851 B

package main
import (
"fmt"
"git.diulo.com/mogfee/protoc-gen-kit/example/service"
"git.diulo.com/mogfee/protoc-gen-kit/middleware"
user "git.diulo.com/mogfee/protoc-gen-kit/proto/v1"
"git.diulo.com/mogfee/protoc-gen-kit/xjson"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"os"
)
func main() {
gin.SetMode(gin.ReleaseMode)
app := gin.Default()
srv := service.UserService{}
l := logrus.New()
f, err := os.Create("./app.log")
if err != nil {
panic(err)
}
defer f.Close()
l.SetOutput(f)
l.SetFormatter(&logrus.JSONFormatter{})
l.SetReportCaller(false)
app.GET("/user/:name", func(c *gin.Context) {
xjson.PrintData(c.FullPath())
})
user.RegisterUserHandler(app, &srv, middleware.JWT(""), middleware.Logger("user-server", l), middleware.Validate())
fmt.Println("http://localhost:8888")
app.Run("localhost:8888")
}