Shrty is a simple to use, go based link shortner with api connection.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

package main
import (
const version = "0.07"
var (
short *shrty.DB
// Global configuration Variable
config = ReadConfig()
func init() {
var err error
short, err = shrty.Open(config.DB)
if err != nil {
type shrt struct {
Token string `bson:"token" json:"token"`
URL string `bson:"url" json:"url"`
Date string `bson:"url_ending" json:"url_ending"`
Count int64 `bson:"click" json:"click"`
func main() {
router := NewRouter()
s := http.StripPrefix("/css/", http.FileServer(http.Dir(path.Join(config.RootPath, "/template/css/"))))
s = http.StripPrefix("/img/", http.FileServer(http.Dir(path.Join(config.RootPath, "/template/img/"))))
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("template/css"))))
http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(http.Dir("template/img"))))
fmt.Printf("Shrty %s is listen on Port: %s \n", version, config.Port)
fmt.Printf("For the API use following key: %s \n", config.APIkey)
http.Handle("/", router)
log.Fatal(http.ListenAndServe(":"+ config.Port, router))