package main import ( "biukop.com/sfm/loan" "fmt" log "github.com/sirupsen/logrus" "net/http" ) func main() { err := config.readConfig() //wechat API config if err != nil { log.Println(err) log.Fatalf("unable to read %s, program quit\n", configFile) return } setupRootFileServer() //always the last one setupHTTPHandler() } func setupRootFileServer() { //root of doc for idx, node := range config.Static { log.Printf("setting up %d static with %+v\n", idx, node) fs := http.FileServer(http.Dir(node.Dir)) http.Handle(node.StaticUrl, http.StripPrefix(node.StripPrefix, fs)) } } func setupHTTPHandler() { http.HandleFunc(apiV1Prefix, apiV1Main) http.HandleFunc("/dummy/", dummyHandler) log.Printf("Server started at %s:%s\n", config.Host, config.Port) log.Fatal(http.ListenAndServe(config.Host+":"+config.Port, nil)) } func dummyHandler(w http.ResponseWriter, r *http.Request) { p := loan.People{} p.FakeNew() fmt.Fprintf(w, "Hello, there %s, %+v\n", loan.Version, p) }