~egtann/srp

2f4d4f3a85f804ac18a018fbe4b24fb822c223aa — Evan Tann 3 years ago e2b97a2
remove pkg/errors dependency
3 files changed, 7 insertions(+), 13 deletions(-)

M cmd/srp/main.go
M go.mod
M proxy.go
M cmd/srp/main.go => cmd/srp/main.go +1 -2
@@ 17,7 17,6 @@ import (
	"time"

	"github.com/egtann/srp"
	"github.com/pkg/errors"
	"golang.org/x/crypto/acme/autocert"
)



@@ 83,7 82,7 @@ func main() {
		go func() {
			err = http.ListenAndServe(":http", m.HTTPHandler(nil))
			if err != nil {
				log.Fatal(errors.Wrap(err, "autocert"))
				log.Fatal(fmt.Printf("listen and serve: %s", err))
			}
		}()
		port = "443"

M go.mod => go.mod +1 -4
@@ 1,6 1,3 @@
module github.com/egtann/srp

require (
	github.com/pkg/errors v0.8.0
	golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb
)
require golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb

M proxy.go => proxy.go +5 -7
@@ 11,8 11,6 @@ import (
	"net/http/httputil"
	"sync"
	"time"

	"github.com/pkg/errors"
)

// ReverseProxy maps frontend hosts to backends. If HealthPath is set in the


@@ 92,12 90,12 @@ func (r *ReverseProxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func NewRegistry(filename string) (Registry, error) {
	byt, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil, errors.Wrapf(err, "read config file %q", filename)
		return nil, fmt.Errorf("read config file %q: %s", filename, err)
	}
	reg := Registry{}
	err = json.Unmarshal(byt, &reg)
	if err != nil {
		return nil, errors.Wrap(err, "unmarshal config")
		return nil, fmt.Errorf("unmarshal config: %s", err)
	}
	for host, v := range reg {
		if len(v.Backends) == 0 {


@@ 187,15 185,15 @@ func ping(job *healthCheck) error {
	target := "http://" + job.ip + job.healthPath
	req, err := http.NewRequest("GET", target, nil)
	if err != nil {
		return errors.Wrap(err, "new request")
		return fmt.Errorf("new request: %s", err)
	}
	client := &http.Client{Timeout: 10 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		return errors.Wrap(err, "do")
		return fmt.Errorf("do: %s", err)
	}
	if err = resp.Body.Close(); err != nil {
		return errors.Wrap(err, "close resp body")
		return fmt.Errorf("close resp body: %s", err)
	}
	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("expected status code 200, got %d",