plugin_matrixsearchfilter

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

Matrix Search Filter

Matrix search filter is a middleware plugin for Traefik which rewrites the HTTP response body for matrix search requests.

Configuration

Static
[pilot]
  token = "xxxx"

[experimental.plugins.rewritebody]
  modulename = "github.com/Awesome-Technologies/traefik-plugin-matrixsearchfilter"
  version = "v0.1.0"
Dynamic

To configure the Matrix Search Filter plugin you should create a middleware in your dynamic configuration as explained here. The following example creates and uses the matrixsearchfilter middleware plugin to remove all external MXIDs in the HTTP response body.

If you want to apply some limits on the response body, you can chain this middleware plugin with the Buffering middleware from Traefik.

[http.routers]
  [http.routers.my-router]
    rule = "Host(`localhost`)"
    middlewares = ["matrix-search-filter"]
    service = "my-service"

[http.middlewares]
  [http.middlewares.matrix-search-filter.plugin.matrixsearchfilter]
    # Keep Last-Modified header returned by the HTTP service.
    # By default, the Last-Modified header is removed.
    lastModified = true
    # Keep all MXIDs with domain part equal to example.com
    userIdRegex = "^@[a-z0-9\._=\-\/\+]+:example\.com$"

[http.services]
  [http.services.my-service]
    [http.services.my-service.loadBalancer]
      [[http.services.my-service.loadBalancer.servers]]
        url = "http://127.0.0.1"

Documentation

Overview

Package plugin_matrixsearchfilter a plugin to rewrite response body of matrix user search.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New creates and returns a new matrix search filter plugin instance.

Types

type Config

type Config struct {
	LastModified bool   `json:"lastModified,omitempty"`
	UserIDRegex  string `json:"userIdRegex,omitempty"`
}

Config holds the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates and initializes the plugin configuration.

type MatrixSearchResult

type MatrixSearchResult struct {
	Limited bool         `json:"limited"`
	Results []MatrixUser `json:"results"`
}

MatrixSearchResult returned in the HTTP response.

type MatrixUser

type MatrixUser struct {
	AvatarURL   string `json:"avatar_url,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
	UserID      string `json:"user_id"`
}

MatrixUser holds a matrix user search result.

Jump to

Keyboard shortcuts

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