parent
2998e1d039
commit
8c04a9ac96
|
@ -411,16 +411,17 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
var conns []*Connection
|
||||
ctx := req.Context()
|
||||
|
||||
f := ln.F{
|
||||
"remote": req.RemoteAddr,
|
||||
"host": req.Host,
|
||||
"uri": req.RequestURI,
|
||||
}
|
||||
|
||||
val, ok := s.domains.Get(req.Host)
|
||||
if ok {
|
||||
conns, ok = val.([]*Connection)
|
||||
if !ok {
|
||||
ln.Error(ctx, ErrNoSuchBackend, ln.F{
|
||||
"action": "no_backend_connected",
|
||||
"remote": req.RemoteAddr,
|
||||
"host": req.Host,
|
||||
"uri": req.RequestURI,
|
||||
})
|
||||
ln.Error(ctx, ErrNoSuchBackend, f, ln.Action("no backend available"))
|
||||
|
||||
return gen502Page(req), nil
|
||||
}
|
||||
|
@ -434,12 +435,7 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
}
|
||||
|
||||
if len(goodConns) == 0 {
|
||||
ln.Error(ctx, ErrNoSuchBackend, ln.F{
|
||||
"action": "no_backend_connected",
|
||||
"remote": req.RemoteAddr,
|
||||
"host": req.Host,
|
||||
"uri": req.RequestURI,
|
||||
})
|
||||
ln.Error(ctx, ErrNoSuchBackend, f, ln.Action("no good backends available"))
|
||||
|
||||
return gen502Page(req), nil
|
||||
}
|
||||
|
@ -448,19 +444,13 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
|
||||
resp, err := c.RoundTrip(req)
|
||||
if err != nil {
|
||||
ln.Error(ctx, err, c, ln.F{
|
||||
"action": "connection_roundtrip",
|
||||
})
|
||||
ln.Error(ctx, err, c, f, ln.Action("connection roundtrip"))
|
||||
|
||||
defer c.cancel()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ln.Log(ctx, c, ln.F{
|
||||
"action": "http traffic",
|
||||
"remote_addr": req.RemoteAddr,
|
||||
"host": req.Host,
|
||||
"uri": req.URL.Path,
|
||||
ln.Log(ctx, c, ln.Action("http traffic"), f, ln.F{
|
||||
"status": resp.Status,
|
||||
"status_code": resp.StatusCode,
|
||||
"content_length": resp.ContentLength,
|
||||
|
@ -474,5 +464,3 @@ type Auth struct {
|
|||
Token string `json:"token"`
|
||||
Domain string `json:"domain"`
|
||||
}
|
||||
|
||||
const defaultUser = "Cadey"
|
||||
|
|
Loading…
Reference in New Issue