package
0.0.0-20211030140731-0fb27046b56b
Repository: https://github.com/smelton01/go-basics.git
Documentation: pkg.go.dev

# README

URL Shortener

Details

An http.Handler looks at the path of any incoming web request and determine if it should redirect the user to a new page.

For instance, if we have a redirect setup for /dogs to https://www.somesite.com/a-story-about-dogs we would look for any incoming web requests with the path /dogs and redirect them.

The MapHandler function uses a predefined map to map the path to the corresponding URL.

The YAMLHandler and JSONHandler functions take a file (-file <filename>) and parses the file for the url paths ans corresponding URLs to redirect users as appropriate. The file parsed depends on the extension of the provided file *.ext.

The DBHandler function checks the database for the provided paths and redirects as appropriate. Set the flag -newdb true to initialize a new database.

Usage

go run main/main.go -newdb true

# Packages

No description provided by the author

# Functions

DBHandler will query the database for provided path and redirect the user to the URL corresponding to the shortcut If the path is not found in the database, then the fallback http.Handler will be called instead.
No description provided by the author
MapHandler will return an http.HandlerFunc that will attempt to map any paths to their corresponding URL If the path is not provided in the map, then the fallback http.Handler will be called instead.
No description provided by the author