Fetch the repository succeeded.
package main
import (
"fmt"
"gitee.com/ccait-dev/fast-api/fast"
"gitee.com/ccait-dev/fast-api/fast/config"
"gitee.com/ccait-dev/fast-api/fast/database/entity"
. "gitee.com/ccait-dev/fast-api/fast/types"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"log"
)
func main() {
fast.BuildServer(&Options{
Handles: HandleMap{
"LoginHandler": func(ctx *gin.Context, params map[string]interface{}, db *gorm.DB, opts *Options) error {
var msg = "this is login"
log.Println(msg)
ctx.JSON(200, entity.ResponseData{Message: msg})
return nil
},
"LogoutHandler": func(ctx *gin.Context, params map[string]interface{}, db *gorm.DB, opts *Options) error {
var msg = "this is logout"
log.Println(msg)
ctx.JSON(200, entity.ResponseData{Message: msg})
return nil
},
"AuthHandler": func(ctx *gin.Context, params map[string]interface{}, db *gorm.DB, opts *Options) error {
var msg = "this is auth"
log.Println(msg)
log.Println("permission -> " + params["permission"].(string))
ctx.JSON(200, entity.ResponseData{Message: msg})
return nil
},
},
OnBeforeStart: func(eng *gin.Engine, config *config.AppConfig) {
eng.Use(func(context *gin.Context) {
fmt.Printf("Handle-----> ")
})
},
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。