You cannot 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
Go

package main
import (
"net/http"
shrty "github.com/kreativmonkey/shrt/shrty"
"log"
8 years ago
"fmt"
)
const version = "0.04"
var (
short *shrty.Store
// Global configuration Variable
config = ReadConfig()
)
func init() {
var err error
short, err = shrty.Open(config.DB)
if err != nil {
panic(err)
}
}
8 years ago
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"`
8 years ago
}
func main() {
router := NewRouter()
8 years ago
8 years ago
s := http.StripPrefix("/css/", http.FileServer(http.Dir("./template/css/")))
router.PathPrefix("/css/").Handler(s)
s = http.StripPrefix("/img/", http.FileServer(http.Dir("./template/img/")))
router.PathPrefix("/img/").Handler(s)
/*
8 years ago
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("template/css"))))
http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(http.Dir("template/img"))))
8 years ago
*/
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)
8 years ago
http.Handle("/", router)
log.Fatal(http.ListenAndServe(":"+ config.Port, router))
8 years ago
}