fast-shortener

command module
v0.0.0-...-264aa39 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: MIT Imports: 5 Imported by: 0

README

Fast Shortener

CircleCI codecov GoDoc

A non-persistent fast URL-shortening service in Golang using valaya/fasthttp and patrickmn/go-cache.

Why use this?

  • Links only persist as long as needed
  • Speed is good
  • You don't like databases

Usage

To shorten https://google.com to hostname/google for 60 seconds, make a request to hostname/put

{
  "url": "https://google.com",
  "key": "google",
  "seconds": 60
}

Prohibited keys:

  • put
  • ok

To be redirected to https://google.com after PUT-ing the above, make a request to hostname/google

Configuration

See config.json

Benchmarks

Ran locally on a mid-2015 15" MBP

BenchmarkPutLink-8   	            500000        2912 ns/op
BenchmarkGetLink-8   	           2000000	       848 ns/op
BenchmarkCacheShortenerPut-8   	 2000000	       727 ns/op
BenchmarkCacheShortenerGet-8   	10000000	       230 ns/op

Development

Clone the repo: go get github.com/davidlu1997/fast-shortener

Tests
  • Run tests: make test
  • Run benchmarks: make benchmark
Run
  • Run server: make run
  • Check health: curl http://localhost:8069/ok
Lint
  • Lint actionable: make lint
  • Lint all: make lint-all

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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