从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 ...
随机推荐
- 学习Linux最简单的方法
大多数初学者在刚刚接触Linux都会有非常陌生的感觉.往往会有一些疑惑和问题.而我们就沿着这些问题,从远及近,从宏观到微观来理解Linux的简洁和美丽. 问题1:Winows有注册表,为什么Linux ...
- JavaScript中的不可变性(Immutability)
什么是不可变性(Immutability)? 即某个变量在进行了某个操作之后,其本身没有发生变化,比如对于字符串而言,对字符串的任何操作都会改变字符串本身的值,而是在字符串的基础上复制出来一个然后再改 ...
- @SafeVarargs注解
被@SafeVarargs注解标注的方法必须是由static或者final修饰的方法. 使用泛型的变长参数方法产生编译器警告的示例: public static <T> T useVara ...
- guava学习:guava集合类型-table
最近学习了下guava的使用,这里简单记录下一些常用并且使用的工具类把. 看到table的使用时候真的是眼前一亮,之前的代码中写过很多的Map<String,Map<String,Stri ...
- git stash使用一则
当在新的分支工作,修改的文件提交到暂存区,这时,切换到其他分之,可能报错,因为米有commit,如果切换到其他分支,暂存区的修改可能丢失,我们可以使用git stash save -a(暂存区) &q ...
- ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash
rails 开发中 5.1版本使用binding.pry会报 ActionController::UnfilteredParameters: unable to convert unpermitted ...
- Physik
0.重点词汇 Der Ortsvektor:位置矢量 Die Verschiebung:位移 Die Geschwendigkeit:速度 Die Beschleunigung:加速度 Die Kre ...
- [转]Format a ui-grid grid column as currency
本文转自:https://stackoverflow.com/questions/27747184/format-a-ui-grid-grid-column-as-currency-rc-3-0 Yo ...
- Java基础之java的四大特性
上篇文章说了jdk的安装和java环境的配置,这篇文章主要说下java的特性. 首相说下,编程语言分为面向过程和面向对象,而java就是一种面向对象的编程语言. 什么是面向过程编程呢?就是一流程为单位 ...
- Fill Table Row(it’s an IQ test question)
Here is a table include the 2 rows. And the cells in the first row have been filled with 0~4. Now yo ...