http - 无法从其他设备访问 Windows Server 上的 Go API
问题描述
我无法在 Windows 服务器上连接到我的 Go API,端口允许,但它仍然不允许我从不同设备连接到 API,但我的 Go API 使用邮递员在 localhost 上工作
更改端口,更改e-channel.ini文件但仍然无法连接
这是我的代码
package main
import (
"flag"
"fmt"
"log"
"net/http"
"./config_db"
"./controller"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
)
func main() {
fileConfig := flag.String("f", "e_channel.ini", "config file")
flag.Parse()
config, err := config_db.LoadConfig(*fileConfig)
if err != nil {
fmt.Println(err.Error())
}
db := config_db.Connectdb()
inDB := &controller.DB{DBE: db}
r := gin.Default()
fmt.Println("Listening at Port " + config.ListeningPort)
r.Run(":" + config.ListeningPort)
}
func root(c *gin.Context) {
c.Header("Content-Type", "application/json")
c.JSON(http.StatusOK, gin.H{
"message": "welcome my api",
})
}
这是我的 e-channel.ini
{
"app_name" : "HELLOWORLD_API",
"listening_port" : "1195",
"host" : "0.0.0.0",
"port" : "3306",
"user" : "root",
"passwd" : "",
"dbname" : "kube71"
}
我希望 API 可以被其他设备访问。
解决方案
推荐阅读
- android - 如果从链接启动,Xamarin Forms WithParentActivityOrWindow 不起作用
- javascript - react redux 应用程序中的空闲超时
- sql - 如何将特定列作为行
- javascript - 有没有一种优雅的方法来检查至少一个元素是否具有某个类?
- google-apps-script - 如何将 Logger.log 内容发布到电子表格单元格中?
- javascript - CSS - 为什么我的 JS 脚本占满高度?
- javascript - 使用 React 钩子实现 shouldComponentUpdate - 仅渲染一次子节点,但在 props 更改时进行 DOM 更改
- prism - 使用 Prism IEventAggregator 跨平台
- fiware - 不同协议的物联网设备能否使用物联网代理相互“对话”?
- reactjs - 反应钩子状态管理时的奇怪行为,splice() 删除了错误的元素