I can't connect to my Go API on windows server, port allowed but still it didn't let me connect to the API from different devices, but my Go API work on localhost using postman
Changing port, change the e-channel.ini file but still can't connect
this is my code
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",
})
}
and this is my e-channel.ini
{
"app_name" : "HELLOWORLD_API",
"listening_port" : "1195",
"host" : "0.0.0.0",
"port" : "3306",
"user" : "root",
"passwd" : "",
"dbname" : "kube71"
}
i hope the API can be accessed by another devices.