module
Version:
v0.0.4
Opens a new window with list of versions in this module.
Published: Apr 21, 2022
License: MIT
Opens a new window with license information.
README
¶
gin-response
安装教程
go get -u gitee.com/xinlong-wang/gin-response
使用说明
package main
import (
"gitee.com/xinlong-wang/gin-response/errcode"
"gitee.com/xinlong-wang/gin-response/response"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.GET("/", func(ctx *gin.Context) {
// xml格式数据响应
response.WrapContextWithXml(ctx).Success("hello,world")
// json
response.DefaultWrapContext(ctx).Success("hello,world")
// 无数据响应
response.DefaultWrapContext(ctx).DefaultError(errcode.ParamRequired)
// 自定义错误信息
response.DefaultWrapContext(ctx).CustomError(1000, "参数错误")
})
router.Run(":8088")
}
Directories
¶
Click to show internal directories.
Click to hide internal directories.