proxy.go 675 B

12345678910111213141516171819202122232425
  1. package gold
  2. import (
  3. "net/http"
  4. "github.com/elazarl/goproxy"
  5. )
  6. var (
  7. proxy = goproxy.NewProxyHttpServer()
  8. )
  9. func init() {
  10. proxy.OnResponse().DoFunc(func(r *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
  11. if r == nil {
  12. return r
  13. }
  14. r.Header.Set("Access-Control-Allow-Credentials", "true")
  15. r.Header.Set("Access-Control-Expose-Headers", "User, Location, Link, Vary, Last-Modified, WWW-Authenticate, Content-Length, Content-Type, Accept-Patch, Accept-Post, Allow, Updates-Via, Ms-Author-Via")
  16. r.Header.Set("Access-Control-Max-Age", "60")
  17. // Drop connection to allow for HTTP/2 <-> HTTP/1.1 compatibility
  18. r.Header.Del("Connection")
  19. return r
  20. })
  21. }