Skip to content

lbb/shrtie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shrtie Build Status GoDoc

What is this ?

This projects aims to provide a small and flexible url shortner

Features

Flexible: Supports several routers such as gorilla/mux, julienschmidt/httprouter and the default http.ServeMux server.

How to get it ?

go get github.com/realfake/shrtie

How to use it ?

Have a look in the examples/ folder.

package main

import (
	"log"
	"net/http"

	"github.com/julienschmidt/httprouter"
	"github.com/realfake/shrtie"
	backend "github.com/realfake/shrtie/backend/redis"
	redis "gopkg.in/redis.v4"
)

func main() {

	b, err := backend.New(&redis.Options{
		Addr:     "localhost:6379",
		Password: "",
		DB:       0,
	})

	if err != nil {
		log.Fatal(err)
	}

	s := shrtie.New(b)
	server := httprouter.New()

	// Get RedirectHandler and warp it
	// into a julienschmidt/httprouter compatible handler function
	server.GET("/s/:id", s.RedirectHandler().Httprouter())
	server.POST("/s", s.SaveHandler().Httprouter())

	server.GET("/info/:id", s.InfoHandler().Httprouter())

	// Start server
	log.Print(http.ListenAndServe(":9999", server))

}

About

Small and dumb URL shortner written in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages