![]() |
il y a 4 ans | |
---|---|---|
crud | il y a 4 ans | |
internal | il y a 4 ans | |
orm | il y a 4 ans | |
scenario | il y a 4 ans | |
time | il y a 4 ans | |
vendor | il y a 4 ans | |
.gitignore | il y a 4 ans | |
README.md | il y a 4 ans | |
api.go | il y a 4 ans | |
go.mod | il y a 4 ans | |
go.sum | il y a 4 ans | |
reset_test.go | il y a 4 ans | |
rest.go | il y a 4 ans |
1.安装包
go get git.nspix.com/golang/rest
初始化rest组件
rest.Initialize(svr.httpSvr, svr.db)
# 如果需要注册校验组件,可以通过下面方式
validator.RegisterCallbacks(svr.db)
注册模型
if err = rest.RegisterModel("webhook", &model.Repository{}); err != nil {
log.Warnf("register repository model error: %s", err.Error())
}
4.驱动选择
4.1 本地驱动,默认驱动为本地驱动
4.2 远程驱动
远程驱动可以把schema
数据写到如远程的数据库,使用方式为
schema.SetDriver(&schema.RemoteDriver{Url: "https://schema.nspix.com/schema"})