You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
898 B

  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. "github.com/fatih/color"
  7. "github.com/gorilla/handlers"
  8. )
  9. func main() {
  10. color.Blue("Starting blockchainIDsystem clientApp")
  11. readConfig("config.json")
  12. fmt.Println(config)
  13. //run thw webserver
  14. go GUI()
  15. //run API
  16. log.Println("api server running")
  17. log.Print("port: ")
  18. log.Println(config.Port)
  19. router := NewRouter()
  20. headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Access-Control-Allow-Origin"})
  21. originsOk := handlers.AllowedOrigins([]string{"*"})
  22. methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"})
  23. log.Fatal(http.ListenAndServe(":"+config.Port, handlers.CORS(originsOk, headersOk, methodsOk)(router)))
  24. }
  25. func GUI() {
  26. //here, run webserver
  27. log.Println("webserver in port " + "8080")
  28. http.Handle("/", http.FileServer(http.Dir("./GUI")))
  29. http.ListenAndServe(":"+"8080", nil)
  30. }