GithubHelp home page GithubHelp logo

go-url-shortener's Introduction

go-url-shortener

go-url-shortener allows you to create short URLs to redirect to any fully-qualified URL, and retrieve the referrals by simply querying the shortened URL.

  • Shortens any URL to a 12-characdter re-direct.
  • Retrieves the fully-qualified URL for any short URL.
  • Accessible via RESTful interface or with provided CLI tool.

Building & Running

For the API:

cd ./cmd && go build -o <name> && ./<name>

For the CLI:

cd .cmd/cli && go build -o <name> && ./<name> <command> <params>

API Interface

Shorten

Accessed via:

POST /shorten/

Request

{
    "url": "https://www.lush.com/uk/en/p/good-karma-everybody-needs-some-shower-gel",
}

Response

{
    "longURL": "https://www.lush.com/uk/en/p/good-karma-everybody-needs-some-shower-gel",
    "shortURL": "https://df.dv/9UhhRFxVDElPV06C",
}

Longen

Accessed via:

GET /

Request

GET https://df.dv/9UhhRFxVDElPV06C

Response

{
    "longURL": "https://www.lush.com/uk/en/p/good-karma-everybody-needs-some-shower-gel",
    "shortURL": "https://df.dv/9UhhRFxVDElPV06C",
}

CLI Commands

The CLI tool supports both shortening and longening of URLs, accessible by running it in one of the two following ways.

Shorten

Request

./cli shorten -shorten-URL=https://www.lush.com/uk/en/p/good-karma-everybody-needs-some-shower-gel

Response

https://df.dv/9UhhRFxVDElPV06C

Longen

Request

./cli longen -longen-URL=kSDOejD9yPsuKRuO

Response

https://www.lush.com/uk/en/p/good-karma-everybody-needs-some-shower-gel

Benchmarks

Handlers

handler name ns/op bytes/op allocs/op
shortenURLHandler 259277 18716 136
retrieveURLHandler 289681 18245 131

App

app name ns/op bytes/op allocs/op
stripURL 2854 105 0
urlShortener 705.7 16 1
validateShortURL 226.2 0 0

DB

db operation ns/op bytes/op allocs/op
Store 1786 230 2
Retrieve 1397 224 3

go-url-shortener's People

Contributors

deanfoley avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.