refactor: restore "First stage of access logging middleware."
This reverts commit 82651985c4
.
This commit is contained in:
parent
db09007dbc
commit
d2c8824902
9 changed files with 473 additions and 30 deletions
|
@ -1,6 +1,7 @@
|
|||
package middlewares
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
@ -10,6 +11,7 @@ import (
|
|||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/containous/traefik/middlewares/accesslog"
|
||||
shellwords "github.com/mattn/go-shellwords"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -64,7 +66,15 @@ func TestLogger(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
logger.ServeHTTP(&logtestResponseWriter{}, r, LogWriterTestHandlerFunc)
|
||||
// Temporary - until new access logger is fully implemented
|
||||
// create the data table and populate frontend and backend
|
||||
core := make(accesslog.CoreLogData)
|
||||
logDataTable := &accesslog.LogData{Core: core, Request: r.Header}
|
||||
logDataTable.Core[accesslog.FrontendName] = testFrontendName
|
||||
logDataTable.Core[accesslog.BackendURL] = testBackendName
|
||||
req := r.WithContext(context.WithValue(r.Context(), accesslog.DataTableKey, logDataTable))
|
||||
|
||||
logger.ServeHTTP(&logtestResponseWriter{}, req, LogWriterTestHandlerFunc)
|
||||
|
||||
if logdata, err := ioutil.ReadFile(logfilePath); err != nil {
|
||||
fmt.Printf("%s\n%s\n", string(logdata), err.Error())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue