Skip to content

Commit

Permalink
Improves connection interface to handle correctly binary and text frames
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Apr 11, 2024
1 parent bae6f36 commit 5c9f71a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ func (b *HTTPBackend) Handle(conn wasabi.Connection, r wasabi.Request) error {
return err
}

return conn.Send(respBody.Bytes())
return conn.Send(respBody.String())
}
2 changes: 1 addition & 1 deletion channel/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *Conn) HandleRequests() {
}

// Send sends message to connection
func (c *Conn) Send(msg []byte) error {
func (c *Conn) Send(msg any) error {
if c.isClosed.Load() || c.ctx.Err() != nil {
return ErrConnectionClosed
}
Expand Down
2 changes: 1 addition & 1 deletion interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type ConnectionRegistry interface {

// Connection is interface for connections
type Connection interface {
Send(msg []byte) error
Send(msg any) error
Context() context.Context
ID() string
HandleRequests()
Expand Down
12 changes: 6 additions & 6 deletions mocks/mock_Connection.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c9f71a

Please sign in to comment.