我在尝试我的 Go Web 在服务器中设置标头。我在用。gorilla/mux和net/http包装。 1 l/ ~% g5 Z" M5 a8 a$ S. G我想设置Access-Control-Allow-Origin: *允许跨域 AJAX。- ]& i( S7 S+ G* e- c L* ]) ~* d( `
这是我的 Go 代码: ) H* j8 G* k; ^) H
func saveHandler(w http.ResponseWriter,r *http.Request) {// do some stuff with the request data}func main() r := mux.NewRouter() r.HandleFunc("/save",saveHandler) http.Handle("/",r) http.ListenAndServe(":" port,nil)}' H5 _6 S$ z r