Skip to content

Commit

Permalink
Merge pull request #81 from getamis/metrics
Browse files Browse the repository at this point in the history
metrics: implement Hijacker interface
  • Loading branch information
unaeat authored Jul 15, 2021
2 parents 6660f4f + 24ed3bb commit 45c0a92
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions metrics/http_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
package metrics

import (
"bufio"
"errors"
"fmt"
"net"
"net/http"
"time"

Expand Down Expand Up @@ -138,6 +141,15 @@ func (r *responseWriter) WriteHeader(status int) {
r.ResponseWriter.WriteHeader(status)
}

// For web socket traffics
func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
hi, ok := rw.ResponseWriter.(http.Hijacker)
if !ok {
return nil, nil, errors.New("not implemented")
}
return hi.Hijack()
}

func (r *responseWriter) Status() int {
if r.status == 0 {
return http.StatusOK
Expand Down

0 comments on commit 45c0a92

Please sign in to comment.