mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
//
|
|
// Copyright (C) 2024 veypi <i@veypi.com>
|
|
// 2025-03-04 16:08:06
|
|
// Distributed under terms of the MIT license.
|
|
//
|
|
// Auto generated by OneBD. DO NOT EDIT
|
|
|
|
package api
|
|
|
|
import (
|
|
"github.com/veypi/OneAuth/api/app"
|
|
"github.com/veypi/OneAuth/api/sms"
|
|
"github.com/veypi/OneAuth/api/token"
|
|
"github.com/veypi/OneAuth/api/user"
|
|
"github.com/veypi/OneAuth/cfg"
|
|
"github.com/veypi/OneAuth/libs/auth"
|
|
"github.com/veypi/OneAuth/oauth"
|
|
"github.com/vyes-ai/vigo"
|
|
"github.com/vyes-ai/vigo/contrib/common"
|
|
)
|
|
|
|
var Router = vigo.NewRouter()
|
|
|
|
func init() {
|
|
// 注册全局中间件
|
|
Router.Use(auth.CheckJWT)
|
|
Router.After(common.JsonResponse, common.JsonErrorResponse)
|
|
|
|
// 注册子资源路由
|
|
Router.Extend("user", user.Router)
|
|
Router.Extend("token", token.Router)
|
|
Router.Extend("app", app.Router)
|
|
Router.Extend("sms", sms.Router)
|
|
Router.Extend("oauth", oauth.Router)
|
|
|
|
// 注册基础接口
|
|
Router.Get("/cfg", "获取配置信息", vigo.SkipBefore, getCfg)
|
|
|
|
// 404 处理
|
|
Router.Any("/**", vigo.SkipBefore, func(x *vigo.X) error {
|
|
return vigo.ErrNotFound
|
|
})
|
|
}
|
|
|
|
func getCfg(x *vigo.X) any {
|
|
return map[string]any{
|
|
"sms": cfg.Config.SMS.Enable,
|
|
}
|
|
}
|