Skip to content

Commit

Permalink
Merge pull request #123 from xmidt-org/add-defaults
Browse files Browse the repository at this point in the history
feat: add a few sane websocket defaults
  • Loading branch information
schmidtw authored May 15, 2024
2 parents f232afc + 07a96a5 commit 8323541
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/websocket/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,17 @@ func (f optionFunc) apply(c *Websocket) error {
return f(c)
}

func emptyDecorator(http.Header) error {
return nil
}

// New creates a new WS connection with the given options.
func New(opts ...Option) (*Websocket, error) {
var ws Websocket
ws := Websocket{
credDecorator: emptyDecorator,
conveyDecorator: emptyDecorator,
client: &http.Client{},
}

opts = append(opts,
validateDeviceID(),
Expand Down
4 changes: 4 additions & 0 deletions internal/websocket/ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,7 @@ func TestLimit(t *testing.T) {
})
}
}

func Test_emptyDecorator(t *testing.T) {
assert.NoError(t, emptyDecorator(http.Header{}))
}

0 comments on commit 8323541

Please sign in to comment.