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.

20 lines
560 B

  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. "github.com/gorilla/handlers"
  6. )
  7. func runRestServer() {
  8. //run API
  9. log.Println("server running")
  10. log.Print("port: ")
  11. log.Println(config.Port)
  12. router := NewRouter()
  13. headersOk := handlers.AllowedHeaders([]string{"X-Requested-With", "Access-Control-Allow-Origin"})
  14. originsOk := handlers.AllowedOrigins([]string{"*"})
  15. methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"})
  16. log.Fatal(http.ListenAndServe(":"+config.Port, handlers.CORS(originsOk, headersOk, methodsOk)(router)))
  17. }