从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 ...
随机推荐
- Window对象的判定方法
/* window对象的判定,由于ECMA是不规范Host对象,window对象属于Host,所以也没有约定,所以就算是Object.prototype也对它无可奈何, 而且如果根据window.wi ...
- Spring Boot的Controller控制层和页面
一.项目实例 1.项目结构 2.项目代码 1).ActionController.Java: package com.example.controller; import java.util.Date ...
- redis集群的搭建详细教程
1 Redis-cluster架构图 redis-cluster投票:容错 (至少要三个才可以,才能超过半数) 架构细节: (1)所有的redis节点彼此互联(PING-PO ...
- hadoop nameNode 无法启动
/************************************************************STARTUP_MSG: Starting NameNodeSTARTUP_M ...
- 玩转树莓派《三》——Scratch
今天大姨妈折磨了一整个白天,稍微好点,现在打开实验楼,看到有个朋友回答了关于ubuntu上面操作SQL 的时候到处数据到txt文件,被批评没有思考问题,或许吧,虽然那个权限我现在想起确实是可读可写的, ...
- 转:详解PV、UV、VV、IP及其关系与计算
一.什么是PV? PV即Page View,网站浏览量,指页面浏览的次数,用以衡量网站用户访问的网页数量.用户每次打开一个页面便记录1次PV,多次打开同一页面则浏览量累计.一般来说,PV与来访者的数量 ...
- Cannot find type definition file for '.svn'
描述: Ionic项目在执行ionic build --prod过程中,出现如下错误: 看来是.svn文件影响了编译. 解决办法:升级TortoiseSVN版本(https://tortoisesvn ...
- OpenFileDialog 打开文件对话框
InitialDirectory 对话框的初始目录 Filter 要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|所有文件(*.*)||*.*" Filt ...
- java常见异常(转载)
版权声明: https://blog.csdn.net/qq_32595075/article/details/80059834 一般面试中java Exception(runtimeExceptio ...
- layui对json数据的格式要求
layui有自己的一套特定的数据格式交互,必须参数code:0,msg:“”,count:数据size(int),data:”数据List”.**一般我们选择封装返回接收类**. 若想要绑定数据到la ...