1 回答

TA貢獻1869條經(jīng)驗 獲得超4個贊
將它們放在單獨的 go 例程中:
router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("/all", All).Methods("GET")
router.HandleFunc("/gotoT", Goto).Methods("GET")
headers := handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"})
methods := handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS"})
origins := handlers.AllowedOrigins([]string{"*"})
corsRouter := handlers.CORS(headers, methods, origins)(router)
go func() {
log.Fatal(http.ListenAndServe(":1111", corsRouter))
}()
go func() {
log.Fatal(http.ListenAndServe(":1112", corsRouter))
}()
log.Fatal(http.ListenAndServe(":1113", corsRouter))
- 1 回答
- 0 關(guān)注
- 172 瀏覽
添加回答
舉報