urlshort

package
v0.0.0-...-456044c Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(inner http.Handler, name string) http.Handler

Logger ...

func MapHandler

func MapHandler(pathsToUrls map[string]string, fallback http.Handler) http.HandlerFunc

MapHandler will return an http.HandlerFunc (which also implements http.Handler) that will attempt to map any paths (keys in the map) to their corresponding URL (values that each key in the map points to, in string format). If the path is not provided in the map, then the fallback http.Handler will be called instead.

func NewRouter

func NewRouter() *mux.Router

NewRouter ...

func YAMLHandler

func YAMLHandler(yaml []byte, fallback http.Handler) (http.HandlerFunc, error)

YAMLHandler will parse the provided YAML and then return an http.HandlerFunc (which also implements http.Handler) that will attempt to map any paths to their corresponding URL. If the path is not provided in the YAML, then the fallback http.Handler will be called instead.

YAML is expected to be in the format:

The only errors that can be returned all related to having invalid YAML data.

See MapHandler to create a similar http.HandlerFunc via a mapping of paths to urls.

Types

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	Queries     []string
	HandlerFunc http.HandlerFunc
}

Route ...

type Routes

type Routes []Route

Routes ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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