shorturl

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2014 License: MIT Imports: 17 Imported by: 5

README

ShortURL

Build Status GoDoc

Generic implementation for interacting with various URL shortening services in Go.

Usage

As usual you can install the package by issuing:

$ go get github.com/subosito/shorturl

Features

Shortening URL

ShortURL provides simple API to shorten a long URL, here's how:

// import "github.com/subosito/shorturl"

provider := "tinyurl"
u, err := shorturl.Shorten("http://example.com/", provider)
if err == nil {
	fmt.Println(u)
}

Alternatively, you can initialize desired provider:

// import "github.com/subosito/shorturl/tinyurl"

s := tinyurl.New()
u, err := s.Shorten("http://example.com/")
if err == nil {
	fmt.Println(u)
}

Expanding short URL

ShortURL also provides simple API to expand short URL into its original long URL:

// import "github.com/subosito/shorturl"

u, err := shorturl.Expand("http://bit.ly/13M3JX5")
if err == nil {
	fmt.Println(u)
}

Notes: Currently, adf.ly is not supported.

Supported Services

Package Service Enviroment Variables
adfly http://adf.ly/ -
bitly https://bitly.com/ BITLY_API_KEY, BITLY_LOGIN
catchy http://catchylink.com/ -
cligs http://cli.gs/ -
gggg http://gg.gg/ -
gitio http://git.io/ -
googl http://goo.gl/ GOOGL_API_KEY
isgd http://is.gd/ -
moourl http://moourl.com/ -
pendekin http://pendek.in/ -
rddme http://rdd.me/ -
shorl http://shorl.com/ -
snipurl http://snipurl.com/ -
tinyurl http://tinyurl.com/ -
vamu http://va.mu/ -

Credits

Inspiration comes from Rubygem shorturl by @robbyrussell

Documentation

Overview

package shorturl providers generic implementation for interacting with various URL shortening services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(u string) ([]byte, error)

func Shorten

func Shorten(u, provider string) ([]byte, error)

Types

type Client

type Client struct {
	Provider string
	Params   map[string]string
}

func NewClient

func NewClient(provider string) *Client

func (*Client) Shorten

func (c *Client) Shorten(u string) ([]byte, error)

Directories

Path Synopsis
package adfly provides support for adf.ly shortening service.
package adfly provides support for adf.ly shortening service.
package base provides HTTP service implementation to communicates with remote providers.
package base provides HTTP service implementation to communicates with remote providers.
package bitly provides support for bit.ly shortening service.
package bitly provides support for bit.ly shortening service.
package catchy provides support for catchylink.com shortening service.
package catchy provides support for catchylink.com shortening service.
package cligs provides support for cli.gs shortening service.
package cligs provides support for cli.gs shortening service.
package gggg provides support for gg.gg shortening service.
package gggg provides support for gg.gg shortening service.
package gitio provides support for git.io, a Github URL shortening services.
package gitio provides support for git.io, a Github URL shortening services.
package googl provides support for goo.gl shortening service.
package googl provides support for goo.gl shortening service.
package isgd provides support for is.gd shortening service.
package isgd provides support for is.gd shortening service.
package moourl provides support for moourl.com shortening service.
package moourl provides support for moourl.com shortening service.
package pendekin provides support for pendek.in shortening service.
package pendekin provides support for pendek.in shortening service.
package rdd.me provides support for rdd.me, a readability's shortening service.
package rdd.me provides support for rdd.me, a readability's shortening service.
package shorl provides support for shorl.com shortening service.
package shorl provides support for shorl.com shortening service.
package snipurl provides support for snipurl.com shortening service.
package snipurl provides support for snipurl.com shortening service.
package tinyurl provides support for tinyurl.com shortening service.
package tinyurl provides support for tinyurl.com shortening service.
package vamu provides support for va.mu shortening service.
package vamu provides support for va.mu shortening service.

Jump to

Keyboard shortcuts

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