You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/cmd/open_im_demo/main.go

50 lines
1.3 KiB

package main
import (
"Open_IM/internal/demo/register"
"Open_IM/pkg/utils"
"flag"
3 years ago
"fmt"
3 years ago
"io"
"os"
"strconv"
"Open_IM/pkg/common/config"
3 years ago
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"github.com/gin-gonic/gin"
)
func main() {
3 years ago
log.NewPrivateLog(constant.LogFileName)
3 years ago
gin.SetMode(gin.ReleaseMode)
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
r := gin.Default()
r.Use(utils.CorsHandler())
3 years ago
authRouterGroup := r.Group("/demo")
{
authRouterGroup.POST("/code", register.SendVerificationCode)
authRouterGroup.POST("/verify", register.Verify)
authRouterGroup.POST("/password", register.SetPassword)
authRouterGroup.POST("/login", register.Login)
3 years ago
authRouterGroup.POST("/reset_password", register.ResetPassword)
}
3 years ago
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
flag.Parse()
3 years ago
fmt.Println("start demo api server, port: ", *ginPort)
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
fmt.Println("start demo api server address: ", address)
err := r.Run(address)
3 years ago
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}
}