-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (39 loc) · 892 Bytes
/
main.go
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
45
46
47
48
49
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"github.com/julienschmidt/httprouter"
)
var version = "unknown"
func usage() {
flag.PrintDefaults()
os.Exit(-1)
}
func main() {
fmt.Println("Glitter\t\t\t\t\t\t", version)
// Initialize configuration
config := parseFlags()
if config.RepoPath == "" {
usage()
}
// Setup Repository
shaderRepo := NewShaderRepository(config.RepoPath)
if err := shaderRepo.Setup(); err != nil {
log.Fatal("Could not setup repository:", err)
}
// Setup HTTP API
router := httprouter.New()
apiRegisterRoutes(&ApiContext{
ShaderRepo: shaderRepo,
}, router)
// Welcome Page
router.GET("/",
func(res http.ResponseWriter, req *http.Request, _ httprouter.Params) {
fmt.Fprintf(res, "WELCOME")
})
log.Println("Listening for HTTP connections on", config.Http.Listen)
http.ListenAndServe(config.Http.Listen, router)
}