diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..8e7d380 --- /dev/null +++ b/circle.yml @@ -0,0 +1,4 @@ +test: + post: + - go vet ./... + diff --git a/normalise_test.go b/normalise_test.go index f489eaf..a537459 100644 --- a/normalise_test.go +++ b/normalise_test.go @@ -15,7 +15,7 @@ var ( expected = []string{"line1", "line2", "line3"} ) -func Testnormaliser(t *testing.T) { +func TestNormaliser(t *testing.T) { for i, first := range endings { for j, second := range endings { for k, suffix := range suffixes { diff --git a/repository.go b/repository.go index 9dd8651..d4b6418 100644 --- a/repository.go +++ b/repository.go @@ -17,13 +17,13 @@ func NewSliceRepository() *SliceRepository { } } -func (repo SliceRepository) indexOfEvent(channel, id string) int { +func (repo *SliceRepository) indexOfEvent(channel, id string) int { return sort.Search(len(repo.events[channel]), func(i int) bool { return repo.events[channel][i].Id() >= id }) } -func (repo SliceRepository) Replay(channel, id string) (out chan Event) { +func (repo *SliceRepository) Replay(channel, id string) (out chan Event) { out = make(chan Event) go func() { defer close(out) diff --git a/stream.go b/stream.go index 5970877..6bcdfb1 100644 --- a/stream.go +++ b/stream.go @@ -53,10 +53,14 @@ func Subscribe(url, lastEventId string) (*Stream, error) { return SubscribeWithRequest(lastEventId, req) } +var redirectingClient = &http.Client{ + CheckRedirect: checkRedirect, +} + // SubscribeWithRequest will take an http.Request to setup the stream, allowing custom headers // to be specified, authentication to be configured, etc. func SubscribeWithRequest(lastEventId string, request *http.Request) (*Stream, error) { - return SubscribeWith(lastEventId, http.DefaultClient, request) + return SubscribeWith(lastEventId, redirectingClient, request) } // SubscribeWith takes a http client and request providing customization over both headers and @@ -70,7 +74,6 @@ func SubscribeWith(lastEventId string, client *http.Client, request *http.Reques Events: make(chan Event), Errors: make(chan error), } - stream.c.CheckRedirect = checkRedirect r, err := stream.connect() if err != nil {