sessionmapper

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

README

SessionMapper GitHub branch checks state

SessionMapper adds properties to your requests based on custom logic. To perform its task, it connects to a Mapping Server that matches sessions to users, groups, roles, experiments, preferences, tracing properties or whatever is needed to provide advanced server-side routing capabilities.

Overview

The SessionMapper middleware for Traefik queries an API and set additional headers before it runs upstream requests. The middleware can be used in front of others. It allows advanced behaviors and applications are limitless... The principle is shown below:

overview

SessionMapper can easily be used and adapted for A/B testing, canary deployment, role-based security, advanced tracing, test collection, personalization...

Configuration

You only need a few parameters to configure the middleware:

  • headers lists the headers to capture from the request and send to the server (default: me)
  • server is the server URL (default: http://localhost:7777/)
  • timeout is the delay in milliseconds before the request to the server fails and no headers are set to the upstream request.

Implementing a SessionMapper Server

For now, the session Mapper is a simple HTTP server that should be colocated to traefik, for instance as a sidecar. The middleware performs a POST to the server URL. The return message would look like below:

{"upstream": {
	"key1": "value1",
	"key2": "value2"
}}

The server directory that is part of the carnage-sh/sessionmapper provides a simple service that implements the current request/response protocol. Next release will improve the protocol to reduce the latency and make it more reliable, including blocking on failure. Do not hesitate to open an issue if you repository find this plugin useful and want to support more advanced scenarios.

Documentation

Overview

a Traefik plugin that map session with additional header properties.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New created a new SessionMapper plugin.

Types

type Config

type Config struct {
	Headers []string `json:"headers,omitempty"`
	Server  string   `json:"server,omitempty"`
	Timeout int      `json:"timeout,omitempty"`
}

Config the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type Response

type Response struct {
	Upstream map[string]string `json:"upstream"`
}

type SessionMapper

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

SessionMapper is the SessionMapper plugin.

func (*SessionMapper) ServeHTTP

func (s *SessionMapper) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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