payment gateway for rpn cn
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ů.

46 lines
1.0KB

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