2023-04-14 17:33:22 +08:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Agent interface {
|
|
|
|
Base
|
|
|
|
RegisterUnAuthRouter(r *gin.RouterGroup)
|
|
|
|
RegisterAuthUserRouter(r *gin.RouterGroup)
|
|
|
|
RegisterAuthAdminRouter(r *gin.RouterGroup)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
CallAgent,
|
|
|
|
registerAgent = MakePlugin[Agent](true)
|
2023-05-29 15:08:03 +08:00
|
|
|
siteURLFn func() string
|
2023-04-14 17:33:22 +08:00
|
|
|
)
|
2023-05-04 15:40:00 +08:00
|
|
|
|
|
|
|
// SiteURL The site url is the domain address of the current site. e.g. http://localhost:8080
|
|
|
|
// When some Agent plugins want to redirect to the origin site, it can use this function to get the site url.
|
|
|
|
func SiteURL() string {
|
2023-05-29 15:08:03 +08:00
|
|
|
if siteURLFn != nil {
|
|
|
|
return siteURLFn()
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterGetSiteURLFunc Register a function to get the site url.
|
|
|
|
func RegisterGetSiteURLFunc(fn func() string) {
|
|
|
|
siteURLFn = fn
|
2023-05-04 15:40:00 +08:00
|
|
|
}
|