Exemplo n.º 1
0
// Initializes service from the command line args
func NewService() (*Service, error) {
	options, err := parseOptions()
	if err != nil {
		return nil, err
	}
	return &Service{options: options, metrics: metrics.NewProxyMetrics()}, nil
}
func (s *ProxySuite) newProxyWithTimeouts(
	code string,
	b backend.Backend,
	l loadbalance.Balancer,
	readTimeout time.Duration,
	dialTimeout time.Duration) *httptest.Server {

	controller := s.newController(code)

	proxySettings := &ProxySettings{
		Controller:       controller,
		ThrottlerBackend: b,
		LoadBalancer:     l,
		HttpReadTimeout:  readTimeout,
		HttpDialTimeout:  dialTimeout,
	}

	s.metrics = metrics.NewProxyMetrics()

	proxy, err := NewReverseProxy(&s.metrics, proxySettings)
	if err != nil {
		panic(err)
	}
	controller.Client = proxy
	return httptest.NewServer(proxy)

}