1
0
Fork 0
empact/server/server.go

37 lines
884 B
Go
Raw Normal View History

2015-03-05 07:46:19 +00:00
package server
import (
2015-03-05 12:57:36 +00:00
"fmt"
2015-03-05 13:49:50 +00:00
"html/template"
2015-03-05 07:46:19 +00:00
"net/http"
2015-03-05 12:57:36 +00:00
2015-03-05 13:49:50 +00:00
"github.com/GeertJohan/go.rice"
2015-03-05 12:57:36 +00:00
)
2015-03-05 13:49:50 +00:00
var (
helloTmpl = template.New("hello")
)
func init() {
box := rice.MustFindBox("static")
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(box.HTTPBox())))
tmplText, _ := box.String("hello.tmpl")
helloTmpl, _ = helloTmpl.Parse(tmplText)
2015-03-05 12:57:36 +00:00
http.HandleFunc("/", sessionHandler)
2015-03-05 15:25:26 +00:00
http.HandleFunc("/api/", authHandler)
http.HandleFunc("/api/orgs", orgsListHandler)
2015-03-05 13:49:50 +00:00
http.HandleFunc("/auth/hello", authHelloHandler)
2015-03-05 07:46:19 +00:00
http.HandleFunc("/auth/signin", authSigninHandler)
http.HandleFunc("/auth/callback", authCallbackHandler)
2015-03-05 13:49:50 +00:00
}
2015-03-05 15:25:26 +00:00
func jsonHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf8")
}
2015-03-05 13:49:50 +00:00
func Start() {
fmt.Println("Starting server at http://localhost:8080")
2015-03-05 07:46:19 +00:00
http.ListenAndServe(":8080", nil)
}