mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 04:50:14 +09:00
22 lines
377 B
Go
22 lines
377 B
Go
package middleware
|
|
|
|
import (
|
|
"chat/connection"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func RegisterMiddleware(app *gin.Engine) func() {
|
|
db := connection.InitMySQLSafe()
|
|
cache := connection.InitRedisSafe()
|
|
|
|
app.Use(CORSMiddleware())
|
|
app.Use(BuiltinMiddleWare(db, cache))
|
|
app.Use(ThrottleMiddleware())
|
|
app.Use(AuthMiddleware())
|
|
|
|
return func() {
|
|
db.Close()
|
|
cache.Close()
|
|
}
|
|
}
|