forked from aurora-develop/aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.go
38 lines (30 loc) · 773 Bytes
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package initialize
import (
"aurora/middlewares"
"github.com/gin-gonic/gin"
)
func RegisterRouter() *gin.Engine {
handler := NewHandle(
checkProxy(),
readAccessToken(),
)
router := gin.Default()
router.Use(middlewares.Cors)
router.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "Hello, world!",
})
})
router.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
router.POST("/auth/session", handler.session)
router.POST("/auth/refresh", handler.refresh)
router.OPTIONS("/v1/chat/completions", optionsHandler)
authGroup := router.Group("").Use(middlewares.Authorization)
authGroup.POST("/v1/chat/completions", handler.nightmare)
authGroup.GET("/v1/models", handler.engines)
return router
}