sus

package module
v0.0.0-...-6d5203b Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: Unlicense Imports: 10 Imported by: 0

README

sus - Simple URL Shortener

Prerequisites

Working linux distribution, go 1.18 compiler and internet connection

Installation and usage
Installation

From the command line

mkdir shortener && cd shortener
git clone https://github.com/petsk0/sus .
go build ./cmd/sus/main.go
./main
Configuration

Configuration of the server is done through command line flags. For more information see:

./main -h
Usage

Assuming all default flags, after running the binary open your web browser and go to localhost:8080.

Insert the URL you wish to shorten into the top text field and press enter (or click the button). Then retrieve your shortened URL from the bottom text field.

Closing the server is done by sending a SIGINT signal to the process (for example by pressing Ctrl+C in the terminal).

Caveats

sus will shorten relative URL paths without prefixing them with schemes or domain names!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheRedirect

func CacheRedirect(h http.HandlerFunc, ttl time.Duration, db *bolt.DB) http.HandlerFunc

func Handle

func Handle(routes []Route) http.HandlerFunc

Types

type Route

type Route struct {
	// contains filtered or unexported fields
}

func NewRoute

func NewRoute(method string, pattern string, h http.HandlerFunc) Route

type Shortener

type Shortener struct {
	// contains filtered or unexported fields
}

func NewShortener

func NewShortener(name string, keylen int, db *bolt.DB) *Shortener

func (*Shortener) HandleGet

func (s *Shortener) HandleGet(w http.ResponseWriter, r *http.Request)

func (*Shortener) HandlePost

func (s *Shortener) HandlePost(w http.ResponseWriter, r *http.Request)

func (*Shortener) HandleRedirect

func (s *Shortener) HandleRedirect(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
cmd
sus

Jump to

Keyboard shortcuts

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