traefik_remove_query_parameters_by_regex

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

README

Info

This middleware allows you to modify the query parameters to the service by removing some parameters by regex. You even can exclude some paths by regex too!

Please note that this is my first middleware and first project with Go. If you have any tips for improvements, please do open a MR and I am more than happy to take a look at it!

I had some great help with looking at previously created plugin. One plugin I learned the most from is https://github.com/kingjan1999/traefik-plugin-query-modification. If you are planning to create a middleware, make sure to check it out!

Check it out on the plugin catalog: https://plugins.traefik.io/plugins/64b138ce498e334469bdbd2a/remove-query-parameters-by-regex

Documentation

Overview

Package traefik_remove_query_parameters_by_regex by Thijmen Stavenuiter.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidModificationType = errors.New("invalid modification type, expected deleteexcept")
	ErrNoConfigurationSet      = errors.New(
		"either AllowedValuesRegex, ExceptURIRegex, or RedirectParams must be set",
	)
	ErrInvalidStatusCode = errors.New("redirectParam statusCode must be 301 or 302")
)

Functions

func New

func New(
	ctx context.Context,
	next http.Handler,
	config *Config,
	name string,
) (http.Handler, error)

New creates a new instance of this plugin.

Types

type Config

type Config struct {
	RedirectParams            []RedirectParam  `json:"redirectParams"`
	AllowedValuesRegex        string           `json:"allowedValuesRegex"`
	ExceptURIRegex            string           `json:"exceptUriRegex"`
	Type                      modificationType `json:"type"`
	AddOriginalHostnameHeader bool             `json:"addOriginalHostnameHeader"`
}

Config is the configuration for this plugin.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates a new configuration for this plugin.

type QueryParameterRemover

type QueryParameterRemover struct {
	// contains filtered or unexported fields
}

QueryParameterRemover represents the basic properties of this plugin.

func (*QueryParameterRemover) ServeHTTP

func (queryParameterRemoverConfig *QueryParameterRemover) ServeHTTP(
	rw http.ResponseWriter,
	req *http.Request,
)

type RedirectParam added in v1.1.0

type RedirectParam struct {
	Param      string `json:"param"`
	StatusCode int    `json:"statusCode"`
}

RedirectParam represents a query parameter and its redirect status code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL