从golang-gin-realworld-example-app项目学写httpapi (七)
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/hello.go
main调用
package main
import (
"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
}
从golang-gin-realworld-example-app项目学写httpapi (七)的更多相关文章
- 从golang-gin-realworld-example-app项目学写httpapi (八)
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/common/unit_test.go 单元测试 ...
- 从golang-gin-realworld-example-app项目学写httpapi (六)
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/validators.go 验证器 ...
- 从golang-gin-realworld-example-app项目学写httpapi (五)
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/middlewares.go 中间件 ...
- 从golang-gin-realworld-example-app项目学写httpapi (四)
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/routers.go 路由定义 pa ...
- 从golang-gin-realworld-example-app项目学写httpapi (三)
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/serializers.go 序列化 ...
- 从golang-gin-realworld-example-app项目学写httpapi (二)
https://github.com/gothinkster/golang-gin-realworld-example-app/blob/master/users/models.go 模型定义 use ...
- 从golang-gin-realworld-example-app项目学写httpapi (一)
https://wangzitian0.github.io/2013/06/29/zero-to-one-1/ https://github.com/gothinkster/golang-gin-re ...
- Golang Gin 项目包依赖管理 godep 使用
Golang Gin 项目包依赖管理 godep 使用 标签(空格分隔): Go 在按照github.com/tools/godep文档go get完包以后,调整项目结构为$GOPATH/src/$P ...
- Golang Gin 项目使用 Swagger
Golang Gin 项目使用 Swagger 标签(空格分隔): Go 首先需要github.com/swaggo/gin-swagger和github.com/swaggo/gin-swagger ...
随机推荐
- windows下Composer因php_openssl扩展缺失而安装失败
Composer(https://getcomposer.org/)是PHP下的一个依赖管理工具.你可以在你的项目中声明你所需要用到的类库,然后Composer会在项目中为你安装它们.如果你了解Nod ...
- 【LDAP】LDAP常用命令解析
ldapadd -x 进行简单认证-D 用来绑定服务器的DN-h 目录服务的地址-w 绑定DN的密码-f 使用ldif文件进行条目添加的文件例子 ldapadd -x -D &qu ...
- springboot-2-ioc
在spring环境下, ioc(控制反转 和 DI (依赖注入) 是等效的, 主要体现一种组合的松耦合思想. spring Ioc容器负责创建Bean, 并将Bean注入到所需的Bean中, 有xml ...
- Mysql日期类型大小比较---拉取给定时间段的记录
我们知道,mysql里边,日期类型有很多表现形式,date, datetime,timestamp等类型.考虑这样一种场景: 按时间段拉取给定时间段的内容,这时,我们就得使用日期类型的比较了. 表结构 ...
- [作业] Python入门基础---购物车小程序
1.购物车小程序: 1.1用户输入工资取60% 1.2打印输出商品菜单 1.3由用户输入数字选择 #__author:Mifen #date: 2018/11/27 # 购物车程序 #把工资作为账户的 ...
- 深入redis内部--实现双向链表
数据结构的应用--Adlist.h定义 1.节点结构 typedef struct listNode { struct listNode *prev; //前向节点 struct lis ...
- Objekt Orientierte Programmierung C++
1.Funtion Overloading C++ erlaubt,dass einige Funktion gleiches Names deklariert wird.Der Formale Pa ...
- [Mysql 查询语句]——分组查询group by
group by (1) group by的含义:将查询结果按照1个或多个字段进行分组,字段值相同的为一组(2) group by可用于单个字段分组,也可用于多个字段分组 select * from ...
- 利用jquery判断点是否在椭圆内
源码例子下载 : <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" ...
- [转]HTTP Error 502.5 - Process Failure asp.net core error in IIS
本文转自:http://www.cnblogs.com/autohome7390/p/6840652.html 在windows server 2012 上安装完dotnet-win-x64.1.1. ...