controllers

package
v0.0.0-...-a23e254 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminHello

func AdminHello(c *gin.Context)

AdminHello 分组路由

func AdminHi

func AdminHi(c *gin.Context)

AdminHi 分组路由2

func HelloForm

func HelloForm(c *gin.Context)

HelloForm 将�form表单提绑定到 struct 上,form-data 这里有 Bind, BindJSON, BindQuery 和 ShouldBind, ShouldBindJSON, ShouldBindQuery 这6中绑定方法 加上 should 就是根据 content-type 一定的自我判定能力,代价就是损耗一些性能

func HelloPage

func HelloPage(c *gin.Context)

HelloPage 基本示例,返回 json 格式内容

func HelloParam

func HelloParam(c *gin.Context)

HelloParam 读取路由中带来的参数

func HelloValidate

func HelloValidate(c *gin.Context)

Types

type HelloValForm

type HelloValForm struct {
	User     string    `form:"user" json:"user" binding:"required"`
	Password string    `form:"password" json:"password" binding:"required"`
	Time     time.Time `form:"time" json:"time" binding:"required,bookabledate" time_format:"2006-01-02"`
}

type LoginForm

type LoginForm struct {
	User     string `form:"user" json:"user" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

LoginForm 在标签中就是映射要读取的字段,同时可以进行字段验证

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL