gopiwik/main.go

30 lines
538 B
Go
Raw Normal View History

2017-03-03 17:44:22 +01:00
package main
import (
"log"
2017-03-03 22:07:39 +01:00
"net/http"
"github.com/dalu/gopiwik/mongo"
"github.com/dalu/gopiwik/piwik"
"gopkg.in/mgo.v2"
2017-03-03 17:44:22 +01:00
)
2017-03-03 22:07:39 +01:00
const (
database = "piwik"
siteCol = "sites"
visitCol = "visits"
)
2017-03-03 17:44:22 +01:00
2017-03-03 22:07:39 +01:00
func main() {
ms, e := mgo.Dial("localhost")
if e != nil {
log.Fatal(e)
}
defer ms.Close()
siteStorage := mongo.NewSiteStorage(ms, database, siteCol)
visitStorage := mongo.NewVisitStorage(ms, database, visitCol)
ph := piwik.NewPiwikHandler(siteStorage, visitStorage)
http.Handle("/", ph)
2017-03-03 17:44:22 +01:00
http.ListenAndServe(":8080", nil)
}