Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test:
post:
- go vet ./...

2 changes: 1 addition & 1 deletion normalise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down