mirror of
https://github.com/zeke-chin/cursor-api.git
synced 2025-10-21 14:29:29 +08:00
整理代码
This commit is contained in:
35
go-capi/main.go
Normal file
35
go-capi/main.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
"go-capi/handlers"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 加载环境变量
|
||||
godotenv.Load()
|
||||
|
||||
r := gin.Default()
|
||||
|
||||
// 配置CORS
|
||||
r.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{"*"},
|
||||
AllowMethods: []string{"GET", "POST",},
|
||||
AllowHeaders: []string{"*"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
|
||||
// 注册路由
|
||||
r.POST("/v1/chat/completions", handlers.ChatCompletions)
|
||||
r.GET("/models", handlers.GetModels)
|
||||
|
||||
// 获取端口号
|
||||
// port := os.Getenv("PORT")
|
||||
port := "3001"
|
||||
|
||||
r.Run(":" + port)
|
||||
}
|
Reference in New Issue
Block a user