Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

57 lines
1.4KB

  1. package main
  2. import (
  3. "biukop.com/sfm/loan"
  4. "fmt"
  5. "log"
  6. "net/http"
  7. )
  8. func main() {
  9. err := config.readConfig() //wechat API config
  10. if err != nil {
  11. log.Println(err)
  12. log.Fatalf("unable to read %s, program quit\n", configFile)
  13. return
  14. }
  15. setupRootFileServer()
  16. //always the last one
  17. setupHTTPHandler()
  18. }
  19. func setupRootFileServer() {
  20. fs := http.FileServer(http.Dir(config.DocRoot))
  21. http.Handle("/", http.StripPrefix("/", fs))
  22. }
  23. func setupHTTPHandler() {
  24. http.HandleFunc("/api", HelloHandler)
  25. http.HandleFunc("/upload", HelloHandler)
  26. http.HandleFunc("/crmfiles/", HelloHandler)
  27. http.HandleFunc("/dumprequest", HelloHandler)
  28. http.HandleFunc("/MP_verify_6JqVkftKr39GMakA.txt", HelloHandler)
  29. http.HandleFunc("/spa/redirect", HelloHandler)
  30. http.HandleFunc("/iapi/getAccessToken", HelloHandler)
  31. http.HandleFunc("/iapi/createWechatQr", HelloHandler)
  32. http.HandleFunc("/crmpixel.png", HelloHandler) //tracking pixel.
  33. http.HandleFunc("/crmcache", HelloHandler)
  34. http.HandleFunc("/spa/editprofile", HelloHandler)
  35. http.HandleFunc("/spa/livecast", HelloHandler)
  36. http.HandleFunc("/spa/editmeeting", HelloHandler)
  37. fmt.Printf("Server started at port %s\n", config.Port)
  38. log.Fatal(http.ListenAndServe(config.Host+":"+config.Port, nil))
  39. }
  40. func HelloHandler(w http.ResponseWriter, r *http.Request) {
  41. p := loan.People{}
  42. p.FakeNew()
  43. fmt.Fprintf(w, "Hello, there %s, %+v\n", loan.Version, p)
  44. }