feature: accesslogger

This commit is contained in:
yusing
2024-12-18 03:09:46 +08:00
parent 34858a1ba0
commit 00f60a6e78
23 changed files with 1116 additions and 71 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/yusing/go-proxy/internal/docker/idlewatcher"
E "github.com/yusing/go-proxy/internal/error"
gphttp "github.com/yusing/go-proxy/internal/net/http"
"github.com/yusing/go-proxy/internal/net/http/accesslog"
"github.com/yusing/go-proxy/internal/net/http/loadbalancer"
loadbalance "github.com/yusing/go-proxy/internal/net/http/loadbalancer/types"
"github.com/yusing/go-proxy/internal/net/http/middleware"
@@ -105,6 +106,15 @@ func (r *HTTPRoute) Start(providerSubtask *task.Task) E.Error {
}
}
if entry.UseAccessLog(r) {
var err error
r.rp.AccessLogger, err = accesslog.NewFileAccessLogger(r.task, r.Raw.AccessLog)
if err != nil {
r.task.Finish(err)
return E.From(err)
}
}
if r.handler == nil {
pathPatterns := r.Raw.PathPatterns
switch {