payment gateway for rpn cn
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

51 lignes
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. svr := Config.Server.Host + ":" + Config.Server.Port
  30. log.Println("Server started on: " + svr)
  31. http.ListenAndServe(svr, nil)
  32. //program never reach here.
  33. }
  34. func errPage(w http.ResponseWriter, code int, msg string) {
  35. var data struct {
  36. ErrorMessage string
  37. }
  38. data.ErrorMessage = msg
  39. w.WriteHeader(code)
  40. t := template.Must(template.ParseFiles("PG/error.html"))
  41. t.Execute(w, data)
  42. }