repo stringlengths 6 47 | file_url stringlengths 77 269 | file_path stringlengths 5 186 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-07 08:35:43 2026-01-07 08:55:24 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/chain/chain.go | pkg/middlewares/chain/chain.go | package chain
import (
"context"
"net/http"
"github.com/containous/alice"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const (
typeName = "Chain"
)
type chainBuilder interface {
BuildChain(ctx context.Context, middlewares []string) *alice.Chain
}
// Ne... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/connectionheader_test.go | pkg/middlewares/auth/connectionheader_test.go | package auth
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRemover(t *testing.T) {
testCases := []struct {
desc string
reqHeaders map[string]string
expected http.Header
}{
{
desc: "simple remove",
reqHeaders: map[string]string{
"Foo"... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/forward.go | pkg/middlewares/auth/forward.go | package auth
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"net"
"net/http"
"net/url"
"regexp"
"strings"
"time"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/accesslog"
"github.com/traefik/traefik/v3/pk... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/digest_auth_test.go | pkg/middlewares/auth/digest_auth_test.go | package auth
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
func TestDigestAuthError(t *testing.T) {
next := ht... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/digest_auth.go | pkg/middlewares/auth/digest_auth.go | package auth
import (
"context"
"fmt"
"net/http"
"net/url"
"strings"
goauth "github.com/abbot/go-http-auth"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/accesslog"
"github.com/traefik/traefik/v3/pkg/middlewa... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/digest_auth_request_test.go | pkg/middlewares/auth/digest_auth_request_test.go | package auth
import (
"crypto/md5"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
"net/http"
"strings"
)
const (
algorithm = "algorithm"
authorization = "Authorization"
nonce = "nonce"
opaque = "opaque"
qop = "qop"
realm = "realm"
wwwAuthenticate = "Www-Authenti... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/connectionheader.go | pkg/middlewares/auth/connectionheader.go | package auth
import (
"net/http"
"net/textproto"
"strings"
"golang.org/x/net/http/httpguts"
)
const (
connectionHeader = "Connection"
upgradeHeader = "Upgrade"
)
// RemoveConnectionHeaders removes hop-by-hop headers listed in the "Connection" header.
// See RFC 7230, section 6.1.
func RemoveConnectionHeade... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/basic_auth_test.go | pkg/middlewares/auth/basic_auth_test.go | package auth
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"os"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
func TestBasicAuthFail(t *testing.T)... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/auth.go | pkg/middlewares/auth/auth.go | package auth
import (
"os"
"strings"
)
// UserParser Parses a string and return a userName/userHash. An error if the format of the string is incorrect.
type UserParser func(user string) (string, string, error)
const (
defaultRealm = "traefik"
authorizationHeader = "Authorization"
)
func getUsers(fileName... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/basic_auth.go | pkg/middlewares/auth/basic_auth.go | package auth
import (
"context"
"fmt"
"net/http"
"net/url"
"strings"
goauth "github.com/abbot/go-http-auth"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/accesslog"
"github.com/traefik/traefik/v3/pkg/middlewa... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/auth/forward_test.go | pkg/middlewares/auth/forward_test.go | package auth
import (
"bytes"
"context"
"fmt"
"io"
"net"
"net/http"
"net/http/httptest"
"net/url"
"strconv"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares/obser... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/ratelimiter/redis_limiter.go | pkg/middlewares/ratelimiter/redis_limiter.go | package ratelimiter
import (
"context"
"fmt"
"strconv"
"time"
"github.com/redis/go-redis/v9"
"github.com/rs/zerolog"
ptypes "github.com/traefik/paerser/types"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"golang.org/x/time/rate"
)
const redisPrefix = "rate:"
type redisLimiter struct {
rate rate.... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/ratelimiter/rate_limiter.go | pkg/middlewares/ratelimiter/rate_limiter.go | // Package ratelimiter implements a rate limiting and traffic shaping middleware with a set of token buckets.
package ratelimiter
import (
"context"
"fmt"
"math"
"net/http"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefi... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/ratelimiter/rate_limiter_test.go | pkg/middlewares/ratelimiter/rate_limiter_test.go | package ratelimiter
import (
"context"
"errors"
"fmt"
"math/rand"
"net/http"
"net/http/httptest"
"os"
"strconv"
"testing"
"time"
"github.com/mailgun/ttlmap"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ptypes "github.com/traefik/paerser/types... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/ratelimiter/in_memory_limiter.go | pkg/middlewares/ratelimiter/in_memory_limiter.go | package ratelimiter
import (
"context"
"fmt"
"time"
"github.com/mailgun/ttlmap"
"github.com/rs/zerolog"
"golang.org/x/time/rate"
)
type inMemoryRateLimiter struct {
rate rate.Limit // reqs/s
burst int64
// maxDelay is the maximum duration we're willing to wait for a bucket reservation to become effective, ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/ratelimiter/lua.go | pkg/middlewares/ratelimiter/lua.go | package ratelimiter
import (
"context"
"github.com/redis/go-redis/v9"
)
type Rediser interface {
Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd
ScriptExists(ctx context.Context, hash... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/tcp/inflightconn/inflight_conn_test.go | pkg/middlewares/tcp/inflightconn/inflight_conn_test.go | package inflightconn
import (
"net"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/tcp"
)
func TestInFlightConn_ServeTCP(t *testing.T) {
proceedCh := make(chan struct{})
waitCh := make(chan struct{})
finishCh := ma... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/tcp/inflightconn/inflight_conn.go | pkg/middlewares/tcp/inflightconn/inflight_conn.go | package inflightconn
import (
"context"
"fmt"
"net"
"sync"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/tcp"
)
const typeName = "InFlightConnTCP"
type inFlightConn struct {
name string
next tcp.Hand... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/tcp/ipallowlist/ip_allowlist_test.go | pkg/middlewares/tcp/ipallowlist/ip_allowlist_test.go | package ipallowlist
import (
"context"
"io"
"net"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/tcp"
)
func TestNewIPAllowLister(t *testing.T) {
testCases := []struct {
desc ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/tcp/ipallowlist/ip_allowlist.go | pkg/middlewares/tcp/ipallowlist/ip_allowlist.go | package ipallowlist
import (
"context"
"errors"
"fmt"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/ip"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/tcp"
)
const (
typeName = "IPAllowListerTCP"
)
// ipAllowLister is a middleware t... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/tcp/ipwhitelist/ip_whitelist_test.go | pkg/middlewares/tcp/ipwhitelist/ip_whitelist_test.go | package ipwhitelist
import (
"context"
"io"
"net"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/tcp"
)
func TestNewIPWhiteLister(t *testing.T) {
testCases := []struct {
desc ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/tcp/ipwhitelist/ip_whitelist.go | pkg/middlewares/tcp/ipwhitelist/ip_whitelist.go | package ipwhitelist
import (
"context"
"errors"
"fmt"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/ip"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/tcp"
)
const (
typeName = "IPWhiteListerTCP"
)
// ipWhiteLister is a middleware t... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/stripprefixregex/strip_prefix_regex_test.go | pkg/middlewares/stripprefixregex/strip_prefix_regex_test.go | package stripprefixregex
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares/stripprefix"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/stripprefixregex/strip_prefix_regex.go | pkg/middlewares/stripprefixregex/strip_prefix_regex.go | package stripprefixregex
import (
"context"
"net/http"
"regexp"
"strings"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/stripprefix"
)
const (
typeName = "StripPrefixRegex"
)
// StripPrefixRegex is a middlewa... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/grpcweb/grpcweb.go | pkg/middlewares/grpcweb/grpcweb.go | package grpcweb
import (
"context"
"net/http"
"github.com/traefik/grpc-web/go/grpcweb"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const typeName = "GRPCWeb"
// New builds a new gRPC web request converter.
func New(ctx context.Context, next http.Handler,... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/denyrouterrecursion/deny_router_recursion_test.go | pkg/middlewares/denyrouterrecursion/deny_router_recursion_test.go | package denyrouterrecursion
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestServeHTTP(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "", nil)
require.NoError(t, err)
_, err = New("", http.HandlerFunc(func(_ ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/denyrouterrecursion/deny_router_recursion.go | pkg/middlewares/denyrouterrecursion/deny_router_recursion.go | package denyrouterrecursion
import (
"errors"
"hash/fnv"
"net/http"
"strconv"
"github.com/containous/alice"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/observability/logs"
)
const xTraefikRouter = "X-Traefik-Router"
type DenyRouterRecursion struct {
routerName string
routerNameHash s... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/requestdecorator/hostresolver.go | pkg/middlewares/requestdecorator/hostresolver.go | package requestdecorator
import (
"context"
"errors"
"fmt"
"net"
"sort"
"strings"
"time"
"github.com/miekg/dns"
"github.com/patrickmn/go-cache"
"github.com/rs/zerolog/log"
)
type cnameResolv struct {
TTL time.Duration
Record string
}
type byTTL []*cnameResolv
func (a byTTL) Len() int { ret... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/requestdecorator/request_decorator_test.go | pkg/middlewares/requestdecorator/request_decorator_test.go | package requestdecorator
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/traefik/traefik/v3/pkg/testhelpers"
"github.com/traefik/traefik/v3/pkg/types"
)
func TestRequestHost(t *testing.T) {
testCases := []struct {
desc string
url string
expected string
}{
{
d... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/requestdecorator/request_decorator.go | pkg/middlewares/requestdecorator/request_decorator.go | package requestdecorator
import (
"context"
"net"
"net/http"
"strings"
"github.com/containous/alice"
"github.com/traefik/traefik/v3/pkg/types"
)
const (
canonicalKey key = "canonical"
flattenKey key = "flatten"
)
type key string
// RequestDecorator is the struct for the middleware that adds the Canonical... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/requestdecorator/hostresolver_test.go | pkg/middlewares/requestdecorator/hostresolver_test.go | package requestdecorator
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCNAMEFlatten(t *testing.T) {
testCases := []struct {
desc string
resolvFile string
domain string
expectedDomain string
}{
{
desc: "host request is CNAME record",
resolvFile:... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/stripprefix/strip_prefix_test.go | pkg/middlewares/stripprefix/strip_prefix_test.go | package stripprefix
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
func TestStripPrefix(t *testing.T) {
testCases := []struct {
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/stripprefix/strip_prefix.go | pkg/middlewares/stripprefix/strip_prefix.go | package stripprefix
import (
"context"
"net/http"
"strings"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const (
// ForwardedPrefixHeader is the default header to set prefix.
ForwardedPrefixHeader = "X-Forwarded-Prefix"
typeName = "StripPre... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/forwardedheaders/forwarded_header.go | pkg/middlewares/forwardedheaders/forwarded_header.go | package forwardedheaders
import (
"net"
"net/http"
"net/textproto"
"os"
"slices"
"strings"
"github.com/traefik/traefik/v3/pkg/ip"
"github.com/traefik/traefik/v3/pkg/proxy/httputil"
"golang.org/x/net/http/httpguts"
)
const (
xForwardedProto = "X-Forwarded-Proto"
xForwardedFor = "X... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/forwardedheaders/forwarded_header_test.go | pkg/middlewares/forwardedheaders/forwarded_header_test.go | package forwardedheaders
import (
"crypto/tls"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestServeHTTP(t *testing.T) {
testCases := []struct {
desc string
insecure bool
trustedIps []string
con... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/metrics/metrics.go | pkg/middlewares/metrics/metrics.go | package metrics
import (
"context"
"net/http"
"slices"
"strconv"
"strings"
"time"
"unicode/utf8"
"github.com/containous/alice"
gokitmetrics "github.com/go-kit/kit/metrics"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/capture"
"... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/metrics/metrics_test.go | pkg/middlewares/metrics/metrics_test.go | package metrics
import (
"net/http"
"net/http/httptest"
"reflect"
"strings"
"testing"
"github.com/go-kit/kit/metrics"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
)
// CollectingCounter is a metrics.Counter implementation that enables access to the CounterValue and LastLabelValues.
typ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/retry/retry_test.go | pkg/middlewares/retry/retry_test.go | package retry
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"net/http/httptrace"
"net/textproto"
"strings"
"testing"
"time"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ptypes "github.com/traefik/paerser/types"
"github.com/traefik/traefik... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/retry/retry.go | pkg/middlewares/retry/retry.go | package retry
import (
"bufio"
"context"
"fmt"
"io"
"math"
"net"
"net/http"
"net/http/httptrace"
"time"
"github.com/cenkalti/backoff/v4"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
"githu... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/mock_tracing_test.go | pkg/middlewares/observability/mock_tracing_test.go | package observability
import (
"context"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
)
type mockTracerProvider struct {
embedded.TracerProvider
}
var _ trace.TracerProvider = mockTracerProvider{}
func (p mock... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/middleware.go | pkg/middlewares/observability/middleware.go | package observability
import (
"context"
"net/http"
"github.com/containous/alice"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/observability/logs"
"github.com/traefik/traefik/v3/pkg/observability/tracing"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
// Traceable e... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/entrypoint_test.go | pkg/middlewares/observability/entrypoint_test.go | package observability
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/observability/tracing"
"go.opentelemetry.io/otel/attribute"
)
func TestEntryPointMiddleware_tracing(t *testing.T) {
type expect... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/service.go | pkg/middlewares/observability/service.go | package observability
import (
"context"
"net/http"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/observability/logs"
"github.com/traefik/traefik/v3/pkg/observability/tracing"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
const (
serviceTypeName ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/service_test.go | pkg/middlewares/observability/service_test.go | package observability
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
func TestNewService(t *testing.T) {
type expected struct {
attributes []attribute.KeyValue
name string
}
testCases :... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/semconv.go | pkg/middlewares/observability/semconv.go | package observability
import (
"context"
"fmt"
"net/http"
"strconv"
"strings"
"time"
"github.com/containous/alice"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/capture"
"github.com/traefik/traefik/v3/pkg/observability/logs"
"git... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/router.go | pkg/middlewares/observability/router.go | package observability
import (
"context"
"net/http"
"github.com/containous/alice"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/observability/logs"
"github.com/traefik/traefik/v3/pkg/observability/tracing"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/o... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/status_code.go | pkg/middlewares/observability/status_code.go | package observability
import (
"bufio"
"net"
"net/http"
)
// newStatusCodeRecorder returns an initialized statusCodeRecoder.
func newStatusCodeRecorder(rw http.ResponseWriter, status int) *statusCodeRecorder {
return &statusCodeRecorder{rw, status}
}
type statusCodeRecorder struct {
http.ResponseWriter
status ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/router_test.go | pkg/middlewares/observability/router_test.go | package observability
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
func TestNewRouter(t *testing.T) {
type expected struct {
attributes []attribute.KeyValue
name string
}
testCases :=... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/semconv_test.go | pkg/middlewares/observability/semconv_test.go | package observability
import (
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/stretchr/testify/require"
ptypes "github.com/traefik/paerser/types"
"github.com/traefik/traefik/v3/pkg/middlewares/capture"
"github.com/traefik/traefik/v3/pkg/observability/metrics"
otypes "github.com/traefik/traefik/v... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/entrypoint.go | pkg/middlewares/observability/entrypoint.go | package observability
import (
"context"
"net/http"
"time"
"github.com/containous/alice"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/observability/tracing"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"go.opentelemet... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/observability/observability.go | pkg/middlewares/observability/observability.go | package observability
import (
"context"
"fmt"
"net/http"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
)
type contextKey int
const observabilityKey contextKey = iota
type Observability struct {
AccessLogsEnabled bool
MetricsEnabled bool
SemConvMetricsEnabled bool
Tracing... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/inflightreq/inflight_req.go | pkg/middlewares/inflightreq/inflight_req.go | package inflightreq
import (
"context"
"fmt"
"net/http"
"github.com/rs/zerolog"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/observability/logs"
"github.com/vulcand/oxy/v2/connlimit"
)
const (
typeName = "InFlightReq"
)... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/capture/capture.go | pkg/middlewares/capture/capture.go | // Package capture is a middleware that captures requests/responses size, and status.
//
// For another middleware to get those attributes of a request/response, this middleware
// should be added before in the middleware chain.
//
// chain := alice.New().
// Append(capture.Wrap).
// Append(myOtherMiddleware)... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/capture/capture_test.go | pkg/middlewares/capture/capture_test.go | package capture
import (
"bytes"
"fmt"
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/containous/alice"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCapture(t *testing.T) {
wrapMiddleware := func(next http.Handler) (http.Handler, error) {
return http.Ha... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/addprefix/add_prefix_test.go | pkg/middlewares/addprefix/add_prefix_test.go | package addprefix
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
func TestNewAddPrefix(t *testing.T) {
testCases := []struct {
desc string
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/addprefix/add_prefix.go | pkg/middlewares/addprefix/add_prefix.go | package addprefix
import (
"context"
"errors"
"net/http"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const (
typeName = "AddPrefix"
)
// AddPrefix is a middleware used to add prefix to an URL request.
type addPrefix struct {
next http.Handler
prefix... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/circuitbreaker/circuit_breaker.go | pkg/middlewares/circuitbreaker/circuit_breaker.go | package circuitbreaker
import (
"context"
"net/http"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
"github.com/traefik/traefik/v3/pkg/o... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/urlrewrite/url_rewrite_test.go | pkg/middlewares/gatewayapi/urlrewrite/url_rewrite_test.go | package urlrewrite
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"k8s.io/utils/ptr"
)
func TestURLRewriteHandler(t *testing.T) {
testCases := []struct {
desc string
config dynamic.URLRewrite
url string... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/urlrewrite/url_rewrite.go | pkg/middlewares/gatewayapi/urlrewrite/url_rewrite.go | package urlrewrite
import (
"context"
"net/http"
"path"
"strings"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const (
typeName = "URLRewrite"
)
type urlRewrite struct {
name string
next http.Handler
hostname *string
path *string
pathPrefi... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/headermodifier/response_header_modifier_test.go | pkg/middlewares/gatewayapi/headermodifier/response_header_modifier_test.go | package headermodifier
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
func TestResponseHeaderModifier(t *testing.T) {
testCases := []struct {
desc string
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/headermodifier/request_header_modifier.go | pkg/middlewares/gatewayapi/headermodifier/request_header_modifier.go | package headermodifier
import (
"context"
"net/http"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const requestHeaderModifierTypeName = "RequestHeaderModifier"
// requestHeaderModifier is a middleware used to modify the headers of an HTTP request.
type req... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/headermodifier/response_header_modifier.go | pkg/middlewares/gatewayapi/headermodifier/response_header_modifier.go | package headermodifier
import (
"context"
"net/http"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const responseHeaderModifierTypeName = "ResponseHeaderModifier"
// requestHeaderModifier is a middleware used to modify the headers of an HTTP response.
type ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/headermodifier/request_header_modifier_test.go | pkg/middlewares/gatewayapi/headermodifier/request_header_modifier_test.go | package headermodifier
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
func TestRequestHeaderModifier(t *testing.T) {
testCases := []struct {
desc string
c... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/redirect/request_redirect_test.go | pkg/middlewares/gatewayapi/redirect/request_redirect_test.go | package redirect
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"k8s.io/utils/ptr"
)
func TestRequestRedirectHandler(t *testing.T) {
testCases := []struct {
desc string
c... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/gatewayapi/redirect/request_redirect.go | pkg/middlewares/gatewayapi/redirect/request_redirect.go | package redirect
import (
"context"
"fmt"
"net"
"net/http"
"path"
"strings"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const typeName = "RequestRedirect"
type redirect struct {
name string
next http.Handler
scheme *string
hostname *string
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/headers/secure_test.go | pkg/middlewares/headers/secure_test.go | package headers
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)
// Middleware tests based on https://github.com/unrolled/secure
func Test_newSecure_modifyResponse(t *testing.T) {
testCases := []struct {
desc stri... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/headers/header.go | pkg/middlewares/headers/header.go | package headers
import (
"fmt"
"net/http"
"regexp"
"strconv"
"strings"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/vulcand/oxy/v2/forward"
)
// Header is a middleware that helps setup a few basic security features.
// A single headerOptions s... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/headers/header_test.go | pkg/middlewares/headers/header_test.go | package headers
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)
func TestNewHeader_customRequestHeader(t *testing.T) {
testCases := []struct {
desc string
cfg dynamic.... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/headers/headers_test.go | pkg/middlewares/headers/headers_test.go | package headers
// Middleware tests based on https://github.com/unrolled/secure
import (
"io"
"net/http"
"net/http/httptest"
"net/http/httptrace"
"net/textproto"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)
func Te... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/headers/secure.go | pkg/middlewares/headers/secure.go | package headers
import (
"net/http"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/unrolled/secure"
)
type secureHeader struct {
next http.Handler
secure *secure.Secure
cfg dynamic.Headers
}
// newSecure constructs a new secure instance wit... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/headers/headers.go | pkg/middlewares/headers/headers.go | // Package headers Middleware based on https://github.com/unrolled/secure.
package headers
import (
"context"
"errors"
"net/http"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const (
typeName = "Headers"
)
type headers struct {
name string
handler h... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/recovery/recovery.go | pkg/middlewares/recovery/recovery.go | package recovery
import (
"bufio"
"context"
"fmt"
"net"
"net/http"
"runtime"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const (
typeName = "Recovery"
middlewareName = "traefik-internal-recovery"
)
type recovery struct {
next http.Handler
}
// New creates recovery middleware.
func New(ctx con... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/recovery/recovery_test.go | pkg/middlewares/recovery/recovery_test.go | package recovery
import (
"errors"
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRecoverHandler(t *testing.T) {
tests := []struct {
desc string
panicErr error
headersSent bool
}{
{
desc: "header... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/snicheck/snicheck_test.go | pkg/middlewares/snicheck/snicheck_test.go | package snicheck
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSNICheck_ServeHTTP(t *testing.T) {
testCases := []struct {
desc string
tlsOptionsForHost map[string]string
host string
expected int
}{
{
desc: "... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/snicheck/snicheck.go | pkg/middlewares/snicheck/snicheck.go | package snicheck
import (
"net"
"net/http"
"strings"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/middlewares/requestdecorator"
traefiktls "github.com/traefik/traefik/v3/pkg/tls"
)
// SNICheck is an HTTP handler that checks whether the TLS configuration for the server name is the same as for ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/buffering/buffering_test.go | pkg/middlewares/buffering/buffering_test.go | package buffering
import (
"bytes"
"crypto/rand"
"math"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)
func TestBuffering(t *testing.T) {
payload := make([]byte, math.MaxInt8)
_, _ = r... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/buffering/buffering.go | pkg/middlewares/buffering/buffering.go | package buffering
import (
"context"
"net/http"
"github.com/rs/zerolog"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/observability/logs"
oxybuffer "github.com/vulcand/oxy/v2/buffer"
)
const (
typeName = "Buffer"
)
type ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/customerrors/custom_errors_test.go | pkg/middlewares/customerrors/custom_errors_test.go | package customerrors
import (
"context"
"fmt"
"io"
"net/http"
"net/http/httptest"
"net/http/httptrace"
"net/textproto"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/customerrors/custom_errors.go | pkg/middlewares/customerrors/custom_errors.go | package customerrors
import (
"bufio"
"context"
"fmt"
"net"
"net/http"
"net/url"
"strconv"
"strings"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
"github.com/traefik/traefik/v3/pkg/types"
"... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/compress/compress.go | pkg/middlewares/compress/compress.go | package compress
import (
"context"
"errors"
"fmt"
"mime"
"net/http"
"slices"
"github.com/andybalholm/brotli"
"github.com/klauspost/compress/gzhttp"
"github.com/klauspost/compress/zstd"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const typeName = "C... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/compress/acceptencoding.go | pkg/middlewares/compress/acceptencoding.go | package compress
import (
"cmp"
"slices"
"strconv"
"strings"
)
const acceptEncodingHeader = "Accept-Encoding"
const (
brotliName = "br"
gzipName = "gzip"
zstdName = "zstd"
identityName = "identity"
wildcardName = "*"
notAcceptable = "not_acceptable"
)
type Encoding struct {
Type string
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/compress/acceptencoding_test.go | pkg/middlewares/compress/acceptencoding_test.go | package compress
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)
func Test_getCompressionEncoding(t *testing.T) {
testCases := []struct {
desc string
acceptEncoding []string
defaultEncoding... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/compress/compression_handler.go | pkg/middlewares/compress/compression_handler.go | package compress
import (
"bufio"
"errors"
"fmt"
"io"
"mime"
"net"
"net/http"
"sync"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
)
const (
vary = "Vary"
acceptEncoding = "Accept-Encoding"
contentEncoding = "Content-Encoding"
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/compress/compression_handler_test.go | pkg/middlewares/compress/compression_handler_test.go | package compress
import (
"bytes"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/andybalholm/brotli"
"github.com/klauspost/compress/zstd"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var (
smallTestBody = []byte("aaabbc" + strings.Repeat("aaabbbccc", 9)... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/compress/compress_test.go | pkg/middlewares/compress/compress_test.go | package compress
import (
"compress/gzip"
"io"
"net/http"
"net/http/httptest"
"net/http/httptrace"
"net/textproto"
"testing"
"github.com/klauspost/compress/gzhttp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/trae... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/ipallowlist/ip_allowlist_test.go | pkg/middlewares/ipallowlist/ip_allowlist_test.go | package ipallowlist
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)
func TestNewIPAllowLister(t *testing.T) {
testCases := []struct {
desc string
allowList dynamic... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/ipallowlist/ip_allowlist.go | pkg/middlewares/ipallowlist/ip_allowlist.go | package ipallowlist
import (
"context"
"errors"
"fmt"
"net/http"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/ip"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
)
const (
type... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/passtlsclientcert/pass_tls_client_cert.go | pkg/middlewares/passtlsclientcert/pass_tls_client_cert.go | package passtlsclientcert
import (
"context"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const typeName = "PassClientTLSCert"
con... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/passtlsclientcert/pass_tls_client_cert_test.go | pkg/middlewares/passtlsclientcert/pass_tls_client_cert_test.go | package passtlsclientcert
import (
"crypto/tls"
"crypto/x509"
"encoding/pem"
"net"
"net/http"
"net/http/httptest"
"net/url"
"regexp"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traef... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/replacepathregex/replace_path_regex_test.go | pkg/middlewares/replacepathregex/replace_path_regex_test.go | package replacepathregex
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares/replacepath"
)
func TestReplacePathRegex(t *testing.T) {
test... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/replacepathregex/replace_path_regex.go | pkg/middlewares/replacepathregex/replace_path_regex.go | package replacepathregex
import (
"context"
"fmt"
"net/http"
"net/url"
"regexp"
"strings"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
"github.com/traefik/traefik/v3/pkg/middlewares/replacepat... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/contenttype/content_type.go | pkg/middlewares/contenttype/content_type.go | package contenttype
import (
"context"
"net/http"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
)
const (
typeName = "ContentType"
)
// ContentType is a middleware used to activate Content-Type auto-detection.
type contentType struct {
next http.Handler
na... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/contenttype/content_type_test.go | pkg/middlewares/contenttype/content_type_test.go | package contenttype
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/testhelpers"
)
func TestAutoDetection(t *testing.T) {
testCases := []struct {
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/replacepath/replace_path_test.go | pkg/middlewares/replacepath/replace_path_test.go | package replacepath
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)
func TestReplacePath(t *testing.T) {
testCases := []struct {
desc string
path string
... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/replacepath/replace_path.go | pkg/middlewares/replacepath/replace_path.go | package replacepath
import (
"context"
"net/http"
"net/url"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/middlewares"
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
)
const (
// ReplacedPathHeader is the default header to set the old path to.
ReplacedPa... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/accesslog/parser.go | pkg/middlewares/accesslog/parser.go | package accesslog
import (
"bytes"
"regexp"
)
// ParseAccessLog parse line of access log and return a map with each fields.
func ParseAccessLog(data string) (map[string]string, error) {
var buffer bytes.Buffer
buffer.WriteString(`(\S+)`) // 1 - ClientHost
buffer.WriteString(`\s-\s`) ... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/accesslog/save_retries_test.go | pkg/middlewares/accesslog/save_retries_test.go | package accesslog
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"testing"
)
func TestSaveRetries(t *testing.T) {
tests := []struct {
requestAttempt int
wantRetryAttemptsInLog int
}{
{
requestAttempt: 0,
wantRetryAttemptsInLog: 0,
},
{
requestAttempt: 1,
w... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/accesslog/logger_formatters_test.go | pkg/middlewares/accesslog/logger_formatters_test.go | package accesslog
import (
"net/http"
"testing"
"time"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCommonLogFormatter_Format(t *testing.T) {
clf := CommonLogFormatter{}
testCases := []struct {
name string
data map[strin... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/accesslog/logger_formatters.go | pkg/middlewares/accesslog/logger_formatters.go | package accesslog
import (
"bytes"
"fmt"
"time"
"github.com/sirupsen/logrus"
)
// default format for time presentation.
const (
commonLogTimeFormat = "02/Jan/2006:15:04:05 -0700"
defaultValue = "-"
)
// CommonLogFormatter provides formatting in the Traefik common log format.
type CommonLogFormatter str... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
traefik/traefik | https://github.com/traefik/traefik/blob/f7280439e6378221a541910f43a01323d52db048/pkg/middlewares/accesslog/parser_test.go | pkg/middlewares/accesslog/parser_test.go | package accesslog
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseAccessLog(t *testing.T) {
testCases := []struct {
desc string
value string
expected map[string]string
}{
{
desc: "full log",
value: `TestHost - TestUser [13/Apr/2016:07:14:19 -0700] "POST testpath HTTP... | go | MIT | f7280439e6378221a541910f43a01323d52db048 | 2026-01-07T08:35:43.502324Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.