Files
OpenList/server/router.go
j2rong4cn 368dc65a6e feat: Implement plugin architecture with gRPC support
- Added driver initialization for gRPC plugins in internal/bootstrap/driver.go.
- Introduced configuration structures and protobuf definitions for driver plugins in proto/driver/config.proto and proto/driver/driver.proto.
- Implemented gRPC server and client interfaces for driver plugins in shared/driver/grpc.go.
- Created common response handling utilities in server/common/common.go and server/common/resp.go.
- Developed plugin registration endpoint in server/handles/plugin.go.
- Added test cases for plugin functionality in shared/driver/plugin_test.go.
- Defined plugin reattachment configuration model in shared/model/plugin.go.
2025-08-13 19:04:38 +08:00

36 lines
816 B
Go

package server
import (
"github.com/OpenListTeam/OpenList/v5/cmd/flags"
"github.com/OpenListTeam/OpenList/v5/internal/conf"
"github.com/OpenListTeam/OpenList/v5/server/handles"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func Init(e *gin.Engine) {
Cors(e)
switch conf.SitePath {
case "", "/":
default:
e.GET("/", func(c *gin.Context) {
c.Redirect(302, conf.SitePath)
})
}
g := e.Group(conf.SitePath)
g.Any("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
if flags.Dev {
g.POST("/plugin/register", handles.PluginRegister)
}
}
func Cors(r *gin.Engine) {
config := cors.DefaultConfig()
config.AllowOrigins = conf.Conf.Cors.AllowOrigins
config.AllowHeaders = conf.Conf.Cors.AllowHeaders
config.AllowMethods = conf.Conf.Cors.AllowMethods
r.Use(cors.New(config))
}