2017-03-03 17:44:22 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2017-03-03 22:07:39 +01:00
|
|
|
"net/http"
|
|
|
|
|
2021-01-06 17:34:05 +01:00
|
|
|
"git.icod.de/dalu/gopiwik/mongo"
|
|
|
|
"git.icod.de/dalu/gopiwik/piwik"
|
2017-03-03 22:07:39 +01:00
|
|
|
"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)
|
|
|
|
}
|