config

package
v0.0.0-...-5b4d3f6 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URLRedirectMW

func URLRedirectMW(next http.Handler, yamlFilePath string) http.HandlerFunc

URLRedirectMW middleware function which acts on request and redirects URL to another URL when it sees path matching another URL defined in yaml file

func YamlMapBuilder

func YamlMapBuilder(yamlFilePath string) map[string]string

YamlMapBuilder builds a map from data present in yaml file as Path and related URL to be redirected to. The map created is used to fetch URL based on path

Types

type Config

type Config struct {
	Map []Mapper `yaml:"mapper"`
}

func YamlHandler

func YamlHandler(yamlFilePath string) (*Config, error)

YamlHandler parses yaml file and unmarshalls yaml bytes into struct defined

type Mapper

type Mapper struct {
	Path string `yaml:"path"`
	URL  string `yaml:"url"`
}

type URLMapper

type URLMapper map[string]string
var (
	PathToURLMap URLMapper
)

func FuseMap

func FuseMap(m1, m2 URLMapper) URLMapper

FuseMap combines 2 maps. m1 & m2 into single map key values present in m2 will over write key value pair from m1 map

Jump to

Keyboard shortcuts

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