RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Go: refactor API route for EE (#17093)
Jin Hai6b8a76c659fe
diff --git a/internal/admin/router.go b/internal/admin/router.goindex 3ba48f8679..e6ee394d7f 100644--- a/internal/admin/router.go+++ b/internal/admin/router.go@@ -58,7 +58,6 @@ func (r *Router) Setup(engine *gin.Engine) {protected := admin.Group("")protected.Use(r.handler.AuthMiddleware()){-protected.POST("/logout", r.handler.Logout)// Authprotected.GET("/auth", r.handler.AuthCheck)@@ -120,136 +119,14 @@ func (r *Router) Setup(engine *gin.Engine) {protected.POST("/sandbox/config", r.handler.SetSandboxConfig)protected.POST("/sandbox/test", r.handler.TestSandboxConnection)- // For enterprise edition- protected.GET("/users/:username/activity", r.handler.ShowUserActivity)- protected.GET("/users/:username/dataset", r.handler.ShowUserDatasetSummary)- protected.GET("/users/:username/summary", r.handler.ShowUserSummary)- protected.GET("/users/:username/storage", r.handler.ShowUserStorage)- protected.GET("/users/:username/quota", r.handler.ShowUserQuota)- protected.GET("/users/:username/index", r.handler.ShowUserIndex)- protected.PUT("/users/:username/role", r.handler.UpdateUserRole)- protected.GET("/users/:username/permission", r.handler.ShowUserPermission)- protected.GET("/users/:username/datasets", r.handler.ListUserDatasets)- protected.GET("/users/:username/agents", r.handler.ListUserAgents)- protected.GET("/users/:username/chats", r.handler.ListUserChats)- protected.GET("/users/:username/searches", r.handler.ListUserSearches)- protected.GET("/users/:username/models", r.handler.ListUserModels)- protected.GET("/users/:username/files", r.handler.ListUserFiles)- protected.GET("/users/:username/providers", r.handler.ListUserProviders)- protected.GET("/users/:username/providers/:provider_name/instances", r.handler.ListUserProviderInstances)- protected.GET("/users/:username/providers/:provider_name/instances/:instance_name/models", r.handler.ListUserProviderInstanceModels)- protected.GET("/users/:username/default-models", r.handler.ListUserDefaultModels)- protected.GET("/users/summary", r.handler.ShowUsersSummary)- protected.GET("/users/activity", r.handler.ShowUsersActivity)- protected.GET("/users/reports", r.handler.ListUsersReports)- protected.GET("/users/storage", r.handler.ListUsersStorage)- protected.GET("/users/documents", r.handler.ListUsersDocuments)- protected.GET("/users/index", r.handler.ListUsersIndex)- protected.GET("/users/quota", r.handler.ListUsersQuota)- protected.GET("/users/plan/summary", r.handler.ShowUsersPlanSummary)- protected.GET("/users/plan", r.handler.ShowUsersPlan)- protected.GET("/users/quota/summary", r.handler.ShowUsersQuotaSummary)- protected.GET("/ingestion/tasks/summary", r.handler.ShowIngestionTasksSummary)- protected.GET("/data/summary", r.handler.ShowDataSummary)- protected.GET("/data/orphan", r.handler.ShowDataOrphan)- protected.GET("/data/storage", r.handler.ShowDataStorage)- protected.GET("/data/index", r.handler.ShowDataIndex)- protected.DELETE("/data/orphan", r.handler.PurgeOrphanData)- protected.DELETE("/users/:username/data", r.handler.PurgeUserData)- protected.DELETE("/users/data", r.handler.PurgeUsersData)-- // API Keys- protected.POST("/users/:username/keys", r.handler.GenerateUserAPIKey)- protected.DELETE("/users/:username/keys/:key", r.handler.DeleteUserAPIKey)- protected.GET("/users/:username/keys", r.handler.ListUserAPIKeys)-- protected.GET("/users/:username/tokens", r.handler.ListUserAPITokens)- //protected.POST("/users/:username/keys", r.handler.GenerateUserAPIToken)- protected.POST("/users/:username/tokens", r.handler.GenerateUserAPIToken)- protected.DELETE("/users/:username/tokens/:token", r.handler.DeleteUserAPIToken)-- // Role management- protected.GET("/roles", r.handler.ListRoles)- protected.POST("/roles", r.handler.CreateRole)- protected.GET("/roles/:role_name", r.handler.ShowRole)- protected.PUT("/roles/:role_name", r.handler.UpdateRole)- protected.DELETE("/roles/:role_name", r.handler.DropRole)- protected.GET("/roles/:role_name/permission", r.handler.ShowRolePermission)- protected.POST("/roles/:role_name/permission", r.handler.GrantRolePermission)- protected.DELETE("/roles/:role_name/permission", r.handler.RevokeRolePermission)- protected.GET("/roles/resource", r.handler.ListResources)- protected.GET("/roles/permission", r.handler.ListRolesWithPermission)- protected.GET("/roles/:role_name/default-models", r.handler.ShowRoleDefaultModels)- protected.PATCH("/roles/:role_name/default-models", r.handler.SetRoleDefaultModel)- protected.DELETE("/roles/:role_name/default-models", r.handler.ResetRoleDefaultModel)-- // Providers and models- provider := protected.Group("/providers")- {- provider.GET("/", r.handler.ListModelProviders)- provider.POST("/", r.handler.AddModelProvider)- provider.GET("/:provider_name", r.handler.ShowProvider)- provider.DELETE("/", r.handler.DeleteModelProvider)- provider.GET("/:provider_name/models", r.handler.ListModels)- provider.GET("/:provider_name/models/:model_name", r.handler.ShowProviderModel)-- provider.POST("/:provider_name/instances", r.handler.AddModelInstance)- provider.GET("/:provider_name/instances", r.handler.ListModelInstances)- provider.DELETE("/:provider_name/instances", r.handler.DeleteModelInstance)- provider.GET("/:provider_name/instances/:instance_name", r.handler.ShowProviderInstance)- provider.GET("/:provider_name/instances/:instance_name/balance", r.handler.ShowProviderInstanceBalance)- provider.GET("/:provider_name/instances/:instance_name/connection", r.handler.CheckInstanceConnection)- provider.POST("/:provider_name/connection", r.handler.CheckProviderConnection)- provider.PUT("/:provider_name/instances/:instance_name", r.handler.AlterProviderInstance)-- provider.GET("/:provider_name/instances/:instance_name/models", r.handler.ListInstanceModels)- provider.PATCH("/:provider_name/instances/:instance_name/models/*model_name", r.handler.EnableOrDisableModel)- provider.POST("/:provider_name/instances/:instance_name/models", r.handler.AddModels)- provider.DELETE("/:provider_name/instances/:instance_name/models", r.handler.DeleteModels)- }-protected.GET("/all-models", r.handler.ListAllModels)protected.GET("/all-models/:model_name", r.handler.ShowModel)- // Sensitive words, EE- protected.GET("/sensitive-words", r.handler.DownloadSensitiveWords)- protected.POST("/sensitive-words", r.handler.UploadSensitiveWords)-- // Verification email, EE- protected.POST("/email/verification", r.handler.BindVerificationEmail)- protected.GET("/email/verification", r.handler.ShowVerificationEmail)-- // White list, EE- protected.GET("/white-list", r.handler.ShowWhiteList)- protected.POST("/white-list", r.handler.AddWhiteList)- protected.POST("/white-list/batch", r.handler.BatchAddWhiteList)- protected.PUT("/white-list/:id", r.handler.UpdateWhiteList)- protected.DELETE("/white-list/:id", r.handler.DeleteWhiteList)- protected.DELETE("/white-list/batch", r.handler.BatchDeleteWhiteList)-// Ingestion tasksprotected.DELETE("/ingestion/tasks", r.handler.RemoveIngestionTasks)protected.PUT("/ingestion/tasks", r.handler.StopIngestionTasks)protected.GET("/ingestion/tasks", r.handler.ListIngestionTasks)- // License- protected.GET("/system/fingerprint", r.handler.GetSystemFingerprint)- protected.POST("/system/license", r.handler.SetSystemLicense)- protected.GET("/system/license", r.handler.ShowSystemLicense)- protected.PUT("/system/license/config", r.handler.UpdateSystemLicenseConfig)-- // Token statistics- protected.GET("/stats/token", r.handler.GetTokenStats)- protected.GET("/stats/token/users", r.handler.GetTokenUsersStats)- protected.GET("/stats/token/summary", r.handler.GetTokenStatsSummary)-- // Fingerprint- protected.GET("/fingerprint", r.handler.GetFingerprint)- // License- protected.POST("/license", r.handler.SetLicense)- protected.POST("/license/config", r.handler.UpdateLicenseConfig)- protected.GET("/license", r.handler.ShowLicense)-RegisterEERouter(protected, r)}}diff --git a/internal/admin/router_ee.go b/internal/admin/router_ee.goindex 28a14f1fdb..cec3595f9d 100644--- a/internal/admin/router_ee.go+++ b/internal/admin/router_ee.go@@ -24,4 +24,119 @@ func SetupEERouter(engine *gin.Engine) {}func RegisterEERouter(protected *gin.RouterGroup, r *Router) {+ // Role management+ protected.GET("/roles", r.handler.ListRoles)+ protected.POST("/roles", r.handler.CreateRole)+ protected.GET("/roles/:role_name", r.handler.ShowRole)+ protected.PUT("/roles/:role_name", r.handler.UpdateRole)+ protected.DELETE("/roles/:role_name", r.handler.DropRole)+ protected.GET("/roles/:role_name/permission", r.handler.ShowRolePermission)+ protected.POST("/roles/:role_name/permission", r.handler.GrantRolePermission)+ protected.DELETE("/roles/:role_name/permission", r.handler.RevokeRolePermission)+ protected.GET("/roles/resource", r.handler.ListResources)+ protected.GET("/roles/permission", r.handler.ListRolesWithPermission)+ protected.GET("/roles/:role_name/default-models", r.handler.ShowRoleDefaultModels)+ protected.PATCH("/roles/:role_name/default-models", r.handler.SetRoleDefaultModel)+ protected.DELETE("/roles/:role_name/default-models", r.handler.ResetRoleDefaultModel)++ // Providers and models+ provider := protected.Group("/providers")+ {+ provider.GET("/", r.handler.ListModelProviders)+ provider.POST("/", r.handler.AddModelProvider)+ provider.GET("/:provider_name", r.handler.ShowProvider)+ provider.DELETE("/", r.handler.DeleteModelProvider)+ provider.GET("/:provider_name/models", r.handler.ListModels)+ provider.GET("/:provider_name/models/:model_name", r.handler.ShowProviderModel)++ provider.POST("/:provider_name/instances", r.handler.AddModelInstance)+ provider.GET("/:provider_name/instances", r.handler.ListModelInstances)+ provider.DELETE("/:provider_name/instances", r.handler.DeleteModelInstance)+ provider.GET("/:provider_name/instances/:instance_name", r.handler.ShowProviderInstance)+ provider.GET("/:provider_name/instances/:instance_name/balance", r.handler.ShowProviderInstanceBalance)+ provider.GET("/:provider_name/instances/:instance_name/connection", r.handler.CheckInstanceConnection)+ provider.POST("/:provider_name/connection", r.handler.CheckProviderConnection)+ provider.PUT("/:provider_name/instances/:instance_name", r.handler.AlterProviderInstance)++ provider.GET("/:provider_name/instances/:instance_name/models", r.handler.ListInstanceModels)+ provider.PATCH("/:provider_name/instances/:instance_name/models/*model_name", r.handler.EnableOrDisableModel)+ provider.POST("/:provider_name/instances/:instance_name/models", r.handler.AddModels)+ provider.DELETE("/:provider_name/instances/:instance_name/models", r.handler.DeleteModels)+ }++ // License+ protected.GET("/system/fingerprint", r.handler.GetSystemFingerprint)+ protected.POST("/system/license", r.handler.SetSystemLicense)+ protected.GET("/system/license", r.handler.ShowSystemLicense)+ protected.PUT("/system/license/config", r.handler.UpdateSystemLicenseConfig)++ protected.GET("/fingerprint", r.handler.GetFingerprint)+ protected.POST("/license", r.handler.SetLicense)+ protected.POST("/license/config", r.handler.UpdateLicenseConfig)+ protected.GET("/license", r.handler.ShowLicense)++ // Stats data info+ protected.GET("/users/:username/activity", r.handler.ShowUserActivity)+ protected.GET("/users/:username/dataset", r.handler.ShowUserDatasetSummary)+ protected.GET("/users/:username/summary", r.handler.ShowUserSummary)+ protected.GET("/users/:username/storage", r.handler.ShowUserStorage)+ protected.GET("/users/:username/quota", r.handler.ShowUserQuota)+ protected.GET("/users/:username/index", r.handler.ShowUserIndex)+ protected.PUT("/users/:username/role", r.handler.UpdateUserRole)+ protected.GET("/users/:username/permission", r.handler.ShowUserPermission)+ protected.GET("/users/:username/datasets", r.handler.ListUserDatasets)+ protected.GET("/users/:username/agents", r.handler.ListUserAgents)+ protected.GET("/users/:username/chats", r.handler.ListUserChats)+ protected.GET("/users/:username/searches", r.handler.ListUserSearches)+ protected.GET("/users/:username/models", r.handler.ListUserModels)+ protected.GET("/users/:username/files", r.handler.ListUserFiles)+ protected.GET("/users/:username/providers", r.handler.ListUserProviders)+ protected.GET("/users/:username/providers/:provider_name/instances", r.handler.ListUserProviderInstances)+ protected.GET("/users/:username/providers/:provider_name/instances/:instance_name/models", r.handler.ListUserProviderInstanceModels)+ protected.GET("/users/:username/default-models", r.handler.ListUserDefaultModels)+ protected.GET("/users/summary", r.handler.ShowUsersSummary)+ protected.GET("/users/activity", r.handler.ShowUsersActivity)+ protected.GET("/users/reports", r.handler.ListUsersReports)+ protected.GET("/users/storage", r.handler.ListUsersStorage)+ protected.GET("/users/documents", r.handler.ListUsersDocuments)+ protected.GET("/users/index", r.handler.ListUsersIndex)+ protected.GET("/users/quota", r.handler.ListUsersQuota)+ protected.GET("/users/plan/summary", r.handler.ShowUsersPlanSummary)+ protected.GET("/users/plan", r.handler.ShowUsersPlan)+ protected.GET("/users/quota/summary", r.handler.ShowUsersQuotaSummary)+ protected.GET("/ingestion/tasks/summary", r.handler.ShowIngestionTasksSummary)+ protected.GET("/data/summary", r.handler.ShowDataSummary)+ protected.GET("/data/orphan", r.handler.ShowDataOrphan)+ protected.GET("/data/storage", r.handler.ShowDataStorage)+ protected.GET("/data/index", r.handler.ShowDataIndex)+ protected.DELETE("/data/orphan", r.handler.PurgeOrphanData)+ protected.DELETE("/users/:username/data", r.handler.PurgeUserData)+ protected.DELETE("/users/data", r.handler.PurgeUsersData)++ // API Keys+ protected.POST("/users/:username/keys", r.handler.GenerateUserAPIKey)+ protected.DELETE("/users/:username/keys/:key", r.handler.DeleteUserAPIKey)+ protected.GET("/users/:username/keys", r.handler.ListUserAPIKeys)++ protected.GET("/users/:username/tokens", r.handler.ListUserAPITokens)+ //protected.POST("/users/:username/keys", r.handler.GenerateUserAPIToken)+ protected.POST("/users/:username/tokens", r.handler.GenerateUserAPIToken)+ protected.DELETE("/users/:username/tokens/:token", r.handler.DeleteUserAPIToken)++ // Sensitive words, EE+ protected.GET("/sensitive-words", r.handler.DownloadSensitiveWords)+ protected.POST("/sensitive-words", r.handler.UploadSensitiveWords)++ // Verification email, EE+ protected.POST("/email/verification", r.handler.BindVerificationEmail)+ protected.GET("/email/verification", r.handler.ShowVerificationEmail)++ // White list, EE+ protected.GET("/white-list", r.handler.ShowWhiteList)+ protected.POST("/white-list", r.handler.AddWhiteList)+ protected.POST("/white-list/batch", r.handler.BatchAddWhiteList)+ protected.PUT("/white-list/:id", r.handler.UpdateWhiteList)+ protected.DELETE("/white-list/:id", r.handler.DeleteWhiteList)+ protected.DELETE("/white-list/batch", r.handler.BatchDeleteWhiteList)+}diff --git a/internal/router/router.go b/internal/router/router.goindex 3b7440a74b..ecbfc57393 100644--- a/internal/router/router.go+++ b/internal/router/router.go@@ -190,17 +190,6 @@ func (r *Router) Setup(engine *gin.Engine) {apiNoAuth.GET("/auth/login/:channel", r.userHandler.OAuthLogin)apiNoAuth.GET("/auth/oauth/:channel/callback", r.userHandler.OAuthChannelCallback)- // For EE- apiNoAuth.GET("/auth/oauth/callback", r.userHandler.OAuthCallback)- apiNoAuth.GET("/auth/oauth/github/callback", r.userHandler.GitHubAuthCallback)- apiNoAuth.GET("/auth/oauth/lark/callback", r.userHandler.LarkAuthCallback)- apiNoAuth.GET("/auth/icbc/callback", r.userHandler.ICBCAuthCallback)- apiNoAuth.GET("/auth/azure/callback", r.userHandler.AzureAuthCallback)- apiNoAuth.GET("/auth/azure/login", r.userHandler.AzureAuthLogin)- apiNoAuth.POST("/auth/register/captcha", r.userHandler.Captcha)- apiNoAuth.POST("/auth/register/otp", r.userHandler.SendOTP)- apiNoAuth.POST("/auth/register/otp/verify", r.userHandler.VerifyOTP)-// RegisterapiNoAuth.POST("/users", r.userHandler.Register)@@ -218,6 +207,8 @@ func (r *Router) Setup(engine *gin.Engine) {apiNoAuth.POST("/auth/password/reset", r.userHandler.ForgotResetPassword)apiNoAuth.GET("/dify/retrieval/health", r.difyRetrievalHandler.HealthCheck)++ RegisterEENoAuthRouter(apiNoAuth, r)}// Beta-token routes. Mirrors python'sdiff --git a/internal/router/router_ee.go b/internal/router/router_ee.goindex e5e6479ba8..7105e192ce 100644--- a/internal/router/router_ee.go+++ b/internal/router/router_ee.go@@ -22,3 +22,16 @@ import (func SetupEERouter(engine *gin.Engine) {}++func RegisterEENoAuthRouter(apiNoAuth *gin.RouterGroup, r *Router) {+ // For EE+ apiNoAuth.GET("/auth/oauth/callback", r.userHandler.OAuthCallback)+ apiNoAuth.GET("/auth/oauth/github/callback", r.userHandler.GitHubAuthCallback)+ apiNoAuth.GET("/auth/oauth/lark/callback", r.userHandler.LarkAuthCallback)+ apiNoAuth.GET("/auth/icbc/callback", r.userHandler.ICBCAuthCallback)+ apiNoAuth.GET("/auth/azure/callback", r.userHandler.AzureAuthCallback)+ apiNoAuth.GET("/auth/azure/login", r.userHandler.AzureAuthLogin)+ apiNoAuth.POST("/auth/register/captcha", r.userHandler.Captcha)+ apiNoAuth.POST("/auth/register/otp", r.userHandler.SendOTP)+ apiNoAuth.POST("/auth/register/otp/verify", r.userHandler.VerifyOTP)+}