mirror of
https://github.com/yudai/gotty.git
synced 2026-01-24 18:26:11 +01:00
Show RemoteAddr and HTTP status code in log
This commit is contained in:
parent
af1a80c962
commit
c88cf7a52d
2 changed files with 27 additions and 3 deletions
23
app/http_logger.go
Normal file
23
app/http_logger.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type responseWrapper struct {
|
||||
http.ResponseWriter
|
||||
status int
|
||||
}
|
||||
|
||||
func (w *responseWrapper) WriteHeader(status int) {
|
||||
w.status = status
|
||||
w.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
func (w *responseWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
hj, _ := w.ResponseWriter.(http.Hijacker)
|
||||
w.status = http.StatusSwitchingProtocols
|
||||
return hj.Hijack()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue