Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

59 lines
1.6KB

  1. package main
  2. import (
  3. "biukop.com/sfm/loan"
  4. "fmt"
  5. log "github.com/sirupsen/logrus"
  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. //root of doc
  21. for idx, node := range config.Static {
  22. log.Printf("setting up %d static with %+v\n", idx, node)
  23. fs := http.FileServer(http.Dir(node.Dir))
  24. http.Handle(node.StaticUrl, http.StripPrefix(node.StripPrefix, fs))
  25. }
  26. }
  27. func setupHTTPHandler() {
  28. http.HandleFunc("/api", HelloHandler)
  29. //http.HandleFunc("/upload", HelloHandler)
  30. //http.HandleFunc("/crmfiles/", HelloHandler)
  31. //http.HandleFunc("/dumprequest", HelloHandler)
  32. //http.HandleFunc("/MP_verify_6JqVkftKr39GMakA.txt", HelloHandler)
  33. //http.HandleFunc("/spa/redirect", HelloHandler)
  34. //http.HandleFunc("/iapi/getAccessToken", HelloHandler)
  35. //http.HandleFunc("/iapi/createWechatQr", HelloHandler)
  36. //http.HandleFunc("/crmpixel.png", HelloHandler) //tracking pixel.
  37. //http.HandleFunc("/crmcache", HelloHandler)
  38. //http.HandleFunc("/spa/editprofile", HelloHandler)
  39. //http.HandleFunc("/spa/livecast", HelloHandler)
  40. //http.HandleFunc("/spa/editmeeting", HelloHandler)
  41. log.Printf("Server started at %s:%s\n", config.Host, config.Port)
  42. log.Fatal(http.ListenAndServe(config.Host+":"+config.Port, nil))
  43. }
  44. func HelloHandler(w http.ResponseWriter, r *http.Request) {
  45. p := loan.People{}
  46. p.FakeNew()
  47. fmt.Fprintf(w, "Hello, there %s, %+v\n", loan.Version, p)
  48. }