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

50 lines
1.2KB

  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. "os"
  6. "text/template"
  7. "time"
  8. )
  9. func main() {
  10. db.h = nil //make sure it's in proper state.
  11. //setup log file
  12. filename := "logs/rpn.superforex." + time.Now().Format("2006-01-02-15-04-06") + ".log"
  13. f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
  14. if err != nil {
  15. log.Fatalf("Error opening file: %v", err)
  16. }
  17. defer f.Close()
  18. log.SetOutput(f)
  19. //Read Config
  20. readConfig()
  21. //readConfigForTest()
  22. //setup http handler
  23. http.HandleFunc("/rpnNameAndCard", rpnNameAndCard) //ask name and card no
  24. http.HandleFunc("/rpn_notify", rpnNotify) //called by rpn
  25. http.HandleFunc("/alipay", leanworkInFAT) // leanwork in
  26. fs := wrapHandler(http.FileServer(http.Dir("./PG"))) //leanwork P2P embeded in
  27. http.HandleFunc("/", fs)
  28. //start listening
  29. log.Println("Server started on: http://localhost:8080")
  30. http.ListenAndServe(Config.Server.Host+":"+Config.Server.Port, nil)
  31. //program never reach here.
  32. }
  33. func errPage(w http.ResponseWriter, code int, msg string) {
  34. var data struct {
  35. ErrorMessage string
  36. }
  37. data.ErrorMessage = msg
  38. w.WriteHeader(code)
  39. t := template.Must(template.ParseFiles("PG/error.html"))
  40. t.Execute(w, data)
  41. }