Files
huangguo_server/swagger/main.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

53 lines
1.1 KiB
Go

package main
import (
"fmt"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"gopkg.in/yaml.v2"
"io/ioutil"
_ "91porn-server/docs"
)
var SwagHandler gin.HandlerFunc
func init() {
SwagHandler = ginSwagger.WrapHandler(swaggerFiles.Handler)
}
type GlobalCfgEx struct {
ListenAddr string `yaml:"listenAddr"`
}
// @title soul2-server 项目API文档
// @version 1.0
// @description 项目接口文档
// @termsOfService soul2-Server
// @contact.name soul2
// @contact.url soul2@gamil.com
// @contact.email soul2@gamil.com
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func main() {
gin.SetMode(gin.ReleaseMode)
buf, err := ioutil.ReadFile("conf/swagger.yaml")
if err != nil {
panic(err)
return
}
conf := GlobalCfgEx{}
if err = yaml.Unmarshal(buf, &conf); err != nil {
panic(err)
return
}
r := gin.Default()
if SwagHandler != nil {
r.GET("/swagger/*any", SwagHandler)
}
fmt.Printf("swagger server start list port:[%v]\n", conf.ListenAddr)
_ = r.Run(fmt.Sprintf(":%v", conf.ListenAddr))
}