This repository was archived by the owner on Aug 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (36 loc) · 1.37 KB
/
main.go
File metadata and controls
44 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"database/sql"
"fmt"
"net/http"
"os"
"pebble-dev/rebblestore-api/common"
"pebble-dev/rebblestore-api/db"
"pebble-dev/rebblestore-api/rebbleHandlers"
"github.com/gorilla/handlers"
_ "github.com/mattn/go-sqlite3"
"github.com/pborman/getopt"
)
func main() {
var version bool
rebbleHandlers.StoreUrl = "http://docs.rebble.io"
getopt.BoolVarLong(&version, "version", 'V', "Get the current version info")
getopt.StringVarLong(&rebbleHandlers.StoreUrl, "store-url", 'u', "Set the store URL (defaults to http://docs.rebble.io)")
getopt.Parse()
if version {
//fmt.Fprintf(os.Stderr, "Version %s\nBuild Host: %s\nBuild Date: %s\nBuild Hash: %s\n", rsapi.Buildversionstring, rsapi.Buildhost, rsapi.Buildstamp, rsapi.Buildgithash)
fmt.Fprintf(os.Stderr, "Version %s\nBuild Host: %s\nBuild Date: %s\nBuild Hash: %s\n", common.Buildversionstring, common.Buildhost, common.Buildstamp, common.Buildgithash)
return
}
database, err := sql.Open("sqlite3", "./RebbleAppStore.db")
if err != nil {
panic("Could not connect to database" + err.Error())
}
dbHandler := db.Handler{database}
// construct the context that will be injected in to handlers
context := &rebbleHandlers.HandlerContext{&dbHandler}
r := rebbleHandlers.Handlers(context)
loggedRouter := handlers.LoggingHandler(os.Stdout, r)
http.Handle("/", r)
http.ListenAndServe(":8080", loggedRouter)
}