-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move global metrics from gin router to runserver level
update configs to use global layer instead of router layer
- Loading branch information
1 parent
2fc4279
commit 58b2a24
Showing
30 changed files
with
440 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package server | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"net" | ||
"net/http" | ||
) | ||
|
||
type TrackingResponseWriter struct { | ||
track *tracking | ||
rw http.ResponseWriter | ||
flusher http.Flusher | ||
hijacker http.Hijacker | ||
} | ||
|
||
func (w *TrackingResponseWriter) Header() http.Header { | ||
return w.rw.Header() | ||
} | ||
|
||
func (w *TrackingResponseWriter) Write(b []byte) (int, error) { | ||
nBytes, e := w.rw.Write(b) | ||
if e != nil { | ||
w.track.writeErrs = append(w.track.writeErrs, e) | ||
} | ||
w.track.responseSize += nBytes | ||
return nBytes, e | ||
} | ||
|
||
func (w *TrackingResponseWriter) WriteHeader(statusCode int) { | ||
w.track.responseStatus = statusCode | ||
w.rw.WriteHeader(statusCode) | ||
} | ||
|
||
func (w *TrackingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { | ||
if w.hijacker != nil { | ||
return w.hijacker.Hijack() | ||
} | ||
return nil, nil, fmt.Errorf("not implemented") | ||
} | ||
|
||
func (w *TrackingResponseWriter) Flush() { | ||
if w.flusher != nil { | ||
w.flusher.Flush() | ||
} | ||
} | ||
|
||
func newTrackingResponseWriter(rw http.ResponseWriter, t *tracking) *TrackingResponseWriter { | ||
return &TrackingResponseWriter{ | ||
track: t, | ||
rw: rw, | ||
flusher: rw.(http.Flusher), | ||
hijacker: rw.(http.Hijacker), | ||
} | ||
} |
Oops, something went wrong.