Skip to content

Commit

Permalink
Merge pull request #21 from strvcom/feat/hijack-response-writer
Browse files Browse the repository at this point in the history
feat: add hijack to response writer
  • Loading branch information
Tomáš Kocman authored Aug 22, 2022
2 parents 5c282f9 + 3a31259 commit 47f3a96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ How to release a new version:

## [Unreleased]

## [0.2.0] - 2022-08-22
### Added
- HTTP response writer implements hijacking to support web sockets.

## [0.1.0] - 2022-08-01
### Added
- Added Changelog.

[Unreleased]: https://github.com/strvcom/strv-backend-go-net/compare/v0.1.0...HEAD
[Unreleased]: https://github.com/strvcom/strv-backend-go-net/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/strvcom/strv-backend-go-net/releases/tag/v0.2.0
[0.1.0]: https://github.com/strvcom/strv-backend-go-net/releases/tag/v0.1.0
11 changes: 11 additions & 0 deletions internal/responsewriter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package internal

import (
"bufio"
"errors"
"net"
"net/http"
"sync/atomic"

Expand Down Expand Up @@ -55,3 +58,11 @@ func (r *ResponseWriter) TryWriteHeader(statusCode int) bool {
}
return false
}

func (r *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
h, ok := r.ResponseWriter.(http.Hijacker)
if !ok {
return nil, nil, errors.New("hijack not supported")
}
return h.Hijack()
}

0 comments on commit 47f3a96

Please sign in to comment.