从golang-gin-realworld-example-app项目学写httpapi

【从golang-gin-realworld-example-app项目学写httpapi】出门莫恨无人随,书中车马多如簇。这篇文章主要讲述从golang-gin-realworld-example-app项目学写httpapi 相关的知识,希望能为你提供帮助。
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/hello.go
main调用

package mainimport ( "fmt""gopkg.in/gin-gonic/gin.v1""github.com/jinzhu/gorm" "github.com/wangzitian0/golang-gin-starter-kit/common" "github.com/wangzitian0/golang-gin-starter-kit/users" )func Migrate(db *gorm.DB) { //users.AutoMigrate() db.AutoMigrate(& users.UserModel{}) db.AutoMigrate(& users.FollowModel{}) }func main() { db := common.Init() Migrate(db) defer db.Close()r := gin.Default()v1 := r.Group("/api") v1.Use(users.AuthMiddleware(true)) users.UsersRegister(v1.Group("/users")) users.UserRegister(v1.Group("/user")) users.ProfileRegister(v1.Group("/profiles"))r.Run() // listen and serve on 0.0.0.0:8080 }


    推荐阅读