In php we can host application and use the same server,port to handle the back-end logic calls.
I've used the following way to achieve this in go-lang. Is there a better way to achieve this?.
r := mux.NewRouter()
http.HandleFunc("/dependencies/", DependencyHandler) //file serving
http.HandleFunc("/portals/", PortalsHandler) //file serving
r.HandleFunc("/registeruser", UserRegistrationHandler)
r.HandleFunc("/deleteuser/{username}", DeleteUserHandler)
http.Handle("/",r)
s := &http.Server{
Addr: ":" + strconv.Itoa(serverConfigs.HttpPort),
Handler: nil,
ReadTimeout: time.Duration(serverConfigs.ReadTimeOut) * time.Second,
WriteTimeout: time.Duration(serverConfigs.WriteTimeOut) * time.Second,
MaxHeaderBytes: 1 << 20,
}