code: func NewProxyServer(filebase string, apiProxyPrefix string, staticPrefix string, filter *FilterServer, cfg *client.Config) (*ProxyServer, error) {
  	host := cfg.Host
  	if !strings.HasSuffix(host, "/") {
  		host = host + "/"
  	}
  	target, err := url.Parse(host)
  	if err != nil {
  		return nil, err
  	}
  	proxy := newProxy(target)
  	if proxy.Transport, err = client.TransportFor(cfg); err != nil {
  		return nil, err
  	}
  	proxyServer := http.Handler(proxy)
  	if filter != nil {
  		proxyServer = filter.HandlerFor(proxyServer)
  	}
  
  	if !strings.HasPrefix(apiProxyPrefix, "/api") {
  		proxyServer = stripLeaveSlash(apiProxyPrefix, proxyServer)
  	}
  
  	mux := http.NewServeMux()
  	mux.Handle(apiProxyPrefix, proxyServer)
  	if filebase != "" {
  		// Require user to explicitly request this behavior rather than
  		// serving their working directory by default.
  		mux.Handle(staticPrefix, newFileHandler(staticPrefix, filebase))
  	}
  	return &ProxyServer{handler: mux}, nil
  }
docs: // NewProxyServer creates and installs a new ProxyServer.
  // It automatically registers the created ProxyServer to http.DefaultServeMux.
  // 'filter', if non-nil, protects requests to the api only.