![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
gin
文章平均质量分 64
今天有怪兽
这个作者很懒,什么都没留下…
展开
-
gin框架的使用(十)——文章添加以及首页展示(代码链接)
代码的压缩包使用的是开源的markdownhttps://pandao.github.io/editor.md/首先是文章列表和添加页面template/article/ArticleList.html{{template "header.html" .}}{{template "nav.html" .}}<!-- 左侧导航和正文内容的分隔线 --><div class="splitter"></div><!-- 正文内容部分 -->&l原创 2021-12-09 16:10:59 · 1027 阅读 · 0 评论 -
gin框架的使用(九)——中间件jwt的使用
这两天比较忙。现在继续搞。jwt验证登录首先是 引入 jwtgo get -u github.com/dgrijalva/jwt-go然后在gin-demo/common/jwt.go中package commonimport ( "errors" "github.com/dgrijalva/jwt-go" "time")type Myclaims struct { Username string `json:"username"` jwt.StandardClaims}原创 2021-12-08 15:58:25 · 1157 阅读 · 0 评论 -
gin框架的使用(八)——文章分类的增删改查
gin框架 加gorm加bootstrap简陋的增删改查原创 2021-12-05 11:08:24 · 1038 阅读 · 0 评论 -
gin框架的使用(七)——用户注册的页面和登录的页面
用户注册和登录的页面以及gin的template的应用原创 2021-12-03 16:44:51 · 2426 阅读 · 4 评论 -
gin框架的使用(六)——viper读配置
viper是用go写的一个配置的工具包,支持很多的文件格式(JSON/TOML/YAML/HCL/envfile/Java properties )接下来先引用进项目go get -u github.com/spf13/viper然后在gin-demo下创建config/config.yaml文件,内容如下:app: Addr: 127.0.0.1 Port: 9663db: DriverName: mysql Database: gin-demo Port: 3306原创 2021-12-03 13:47:47 · 1703 阅读 · 0 评论 -
gin框架的使用(五)——整理代码之router和response
router路由在gin-demo目录下建立router/router.gorouter.gopackage routerimport ( "gin-demo/controller" "github.com/gin-gonic/gin")func InitRouter(r *gin.Engine) *gin.Engine{ //注册 r.POST("/user/register",controller.Register) //登录 r.POST("/user/login",.原创 2021-12-02 20:17:50 · 1302 阅读 · 0 评论 -
gin框架的使用(四)——用户登录
在gin-demo/controller/user.go 中写登录的方法package controllerimport "C"import ( "gin-demo/common" "gin-demo/model" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "golang.org/x/crypto/bcrypt" "math/rand" "net/http" "time")// Register 用户注册func原创 2021-12-02 16:44:17 · 3173 阅读 · 2 评论 -
gin框架的使用(三)——用户注册
在gin-demo下创建model目录,目录下创建user.go来写user的结构体user.go的内容如下:package model// Usertype User struct { ID int `gorm:"primaryKey"`//设置为主键 Username string `gorm:"not null;unique;size:255"`//唯一,不为空 Password string `gorm:"not null"` Mobile string `gorm:"uniqu原创 2021-12-02 13:39:17 · 1951 阅读 · 0 评论 -
gin框架的使用(二)——gorm的安装
gorm的安装及数据库的初始化。原创 2021-12-01 15:05:22 · 1931 阅读 · 0 评论