I'm building a rest API in Go. I have an SSL domain and one dedicated server.
The domain points to my dedicated and works fine (https://www.myweb.com).
The error is when I'm making a request to some EndPoint of my API I do never get a response from the server.
func main() {
router := NewRouter()
handler := cors.New(cors.Options{
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH"},
AllowCredentials: true,
AllowedOrigins: []string{"*"},
AllowedHeaders: []string{"Authorization", "Content-Type", "Access-Control-Allow-Request-Method"},
}).Handler(router)
log.Fatal(http.ListenAndServeTLS(":4433", "tls.crt", "tls.key", handler))
}
routes.go:
var routes = Routes{ Route{"Index", "GET", "/", Index}, }
func NewRouter() *mux.Router {
fmt.Println("[INFO] Loading EndPoints...")
router := mux.NewRouter().StrictSlash(true)
for _, route := range routes {
router.
Methods(route.Method).
Path(endPoint + route.Pattern).
Name(route.Name).
Handler(route.HandlerFunc).Headers()
}
fmt.Println("[INFO] EndPoints loaded successfully...")
return router
}
Index function
func Index(w http.ResponseWriter, r *http.Request) {
fmt.Println("API IS RIGHT HERE latest")
w.WriteHeader(http.StatusOK)
w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
w.Write([]byte("This is an example server.
"))
}
The problem is that I can see 'API IS RIGHT HERE latest' in the console but nothing else. I mean, the response is not loading. This is the POSTMAN message
UPDATE
I just noticed that If I use the link and join over Firefox browser then the response works okay. But if I request the same URL from POSTMAN then I don't get a response.
UPDATE 2
I just disabled SSL Verification from POSTMAN and now works fine. But I wanna know what really means this option? Because I bought an SSL Certificate (It's not a self-signed)