This commit is contained in:
zhiqiang feng
2020-09-15 10:24:08 +08:00
parent cf86eadf63
commit 6c1744eaea
+12 -3
View File
@@ -2,6 +2,7 @@ package main
import ( import (
"net/http" "net/http"
"os"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gzzn.com/mini/ciimsproxy/internal" "gzzn.com/mini/ciimsproxy/internal"
@@ -10,20 +11,28 @@ import (
const ( const (
servicePrefix string = "/services/ExchangeService" servicePrefix string = "/services/ExchangeService"
// defaultURL string = "http://localhost:8080" // defaultURL string = "http://localhost:8080"
defaultURL string = "http://192.168.10.96:8080" //defaultURL string = "http://192.168.10.96:8080"
) )
var defaultURL = ""
func main() { func main() {
defaultURL = os.Getenv("CIIMS_SERVER")
listen := os.Getenv("PROXY_LISTEN")
if listen == "" {
listen = ":9090"
}
println("use ciims : " + defaultURL)
r := gin.Default() r := gin.Default()
r.GET("/ping", func(c *gin.Context) { r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"message": "pong", "message": "pong",
}) })
}) })
r.POST("/msg", sendMessage) r.POST("/send", sendMessage)
r.POST("/receive", receiveMessage) r.POST("/receive", receiveMessage)
// r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") // r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
r.Run(":9090") r.Run(listen)
} }
func sendMessage(c *gin.Context) { func sendMessage(c *gin.Context) {