src

package
v0.0.0-...-8c33d56 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *sql.DB

Functions

func DisplayIndex

func DisplayIndex(w http.ResponseWriter, r *http.Request)

func GenerateHash

func GenerateHash(rawUrl string) string

Generate hash of the url

func GenerateId

func GenerateId(n int) string

Generate a random string of length n

func GetQualifiedTinyUrl

func GetQualifiedTinyUrl(r *http.Request, id string) string

GetQualifiedTinyUrl returns the qualified tinyurl

func JsonError

func JsonError(w http.ResponseWriter, err interface{}, code int)

JSONError writes an error to the response

func RedirectUrl

func RedirectUrl(w http.ResponseWriter, r *http.Request)

func ShortenUrl

func ShortenUrl(w http.ResponseWriter, r *http.Request)

func TrimSlash

func TrimSlash(rawUrl string) string

Strip trailing slash from url

func ValidateUrl

func ValidateUrl(rawUrl string) bool

ValidateUrl checks if a given URL is valid

Types

type Request

type Request struct {
	Url string `json:"url"`
}

type Response

type Response struct {
	TinyUrl string `json:"tinyurl"`
}

Jump to

Keyboard shortcuts

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