shortie

package module
v0.0.0-...-9841b9d Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Src tiny entropy Pool
	Src = rand.NewSource(time.Now().UnixNano())
	// Pool KV memory DB
	Pool *cache.Cache
	// URLSize is the default size of the shortened URL
	URLSize int = 10
	// Port is the listening port address
	Port int = 8080
	// Exp is the expiration time of the shortened URL
	Exp time.Duration = 240 * time.Hour
	// Cleanup is the clean up time interval
	Cleanup time.Duration = 1 * time.Hour
	// Proto is the shortened URL protocol
	Proto string = "https"
	// Domain is the shortened URL domain
	Domain string = "localhost"
	// Path is the shortened URL prefix path
	Path string = ""
	// DumpFile is the file to dump URL data
	DumpFile string = "urls.json"
)

Functions

func Dump

func Dump(t *template.Template) func(ctx *fasthttp.RequestCtx)

Dump return a fasthttp.RequestHandler function that dumps the contents of the KV db to the ctx handler

func FromFile

func FromFile(t *template.Template) func(ctx *fasthttp.RequestCtx)

FromFile return a fasthttp.RequestHandler function that loads the content of the DumpFile into the KV db

func FromPost

func FromPost(t *template.Template) func(ctx *fasthttp.RequestCtx)

FromPost return a fasthttp.RequestHandler function that loads the content of the JSON POST into the KV db

func IndexHandler

func IndexHandler(t *template.Template) func(ctx *fasthttp.RequestCtx)

IndexHandler return a fasthttp.RequestHandler function that genetares the index page

func Redir

func Redir(t *template.Template) func(ctx *fasthttp.RequestCtx)

Redir return a fasthttp.RequestHandler function that genetares the shortener redirect page

func Short

func Short(t *template.Template) func(ctx *fasthttp.RequestCtx)

Short return a fasthttp.RequestHandler function that genetares the shortener page

func ToFile

func ToFile(t *template.Template) func(ctx *fasthttp.RequestCtx)

ToFile return a fasthttp.RequestHandler function that dumps the contents of the KV db to the DumpFile file

Types

This section is empty.

Jump to

Keyboard shortcuts

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