url-shortener-go

command module
v0.0.0-...-3701de1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: MIT Imports: 10 Imported by: 0

README

url-shortener-go

Simple URL shortener written in Go

Overview

Читайте на русском здесь.

URL Shortner provides two kinds of URL storages. The first one wraps map data structure native in GO and makes it thread-sage. Unfortunately, the current implementation guarantee reliable storing. So in case of persistent storage is main requirement the second one was introduced which is based on Bolt DB. Waranties and properties of shortener implementation are pointed the following out.

  1. Thread-safe for new URL shornening.
  2. Time to live and base URL are parameters.
  3. Configuration could be specified in toml-file.
  4. Two kinds of URL storages.
  5. Guarantee persistence of short URLs with storage based on Bolt DB.
  6. Work correctly behind proxy or balancer.

In order to start url-shortener-go by oneself with persistency storing of URLS one could just run

    ./url-shortener --url-storage bolt

Or one could register it as a system service defined with systemd unit file and could run it.

Try it here.

API Methods

One could create new short URL with simple request to /shorten/ URI parametrized with url which is target link.

    curl -v -X POST http://localhost:8080/shorten/?url=https://google.com

Server replies with 201(Created) response that contains short URL in Location header and duplicates it in response body.

Performing request to short URL created before server replies with 302(Found/Moved Temporary) response and sets Location header referred to original URL.

    curl -v http://localhost:8080/ri0xJwQ6

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