2016-11-21 12:24:50 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/dannyvankooten/ana/core"
|
|
|
|
"github.com/dannyvankooten/ana/api"
|
|
|
|
)
|
|
|
|
|
2016-11-21 16:36:25 +00:00
|
|
|
// TODO: Use Gorilla Mux router.
|
|
|
|
// TODO: Authentication.
|
2016-11-21 12:24:50 +00:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
db := core.SetupDatabaseConnection()
|
|
|
|
defer db.Close()
|
|
|
|
|
2016-11-21 15:01:14 +00:00
|
|
|
// register routes
|
|
|
|
api.RegisterRoutes()
|
2016-11-21 12:24:50 +00:00
|
|
|
http.HandleFunc("/collect", api.CollectHandler)
|
|
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
http.ServeFile(w, r, "./static/" + r.URL.Path[1:])
|
|
|
|
})
|
|
|
|
http.ListenAndServe(":8080", nil)
|
|
|
|
}
|