|
- package main
-
- import (
- "log"
- "net/http"
- "os"
- "text/template"
- "time"
- )
-
- func main() {
- //readConfig()
- readConfigForTest()
- db.h = nil //make sure it's in proper state.
-
- filename := "rpn.superforex." + time.Now().Format("20060102150406") + ".log"
- f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
- if err != nil {
- log.Fatalf("error opening file: %v", err)
- }
- defer f.Close()
- log.SetOutput(f)
- log.Println("Server started on: http://localhost:8080")
-
- //setup http handler
- http.HandleFunc("/choosePayment", choosePayment)
- http.HandleFunc("/rpnNameAndCard", rpnNameAndCard)
- http.HandleFunc("/rpn_notify", rpnNotify) //called by rpn
- fs := wrapHandler(http.FileServer(http.Dir("./PG")))
- http.HandleFunc("/", fs)
- http.ListenAndServe(":8080", nil)
-
- //start log file
-
- }
-
- func errPage(w http.ResponseWriter, code int, msg string) {
- var data struct {
- ErrorMessage string
- }
- data.ErrorMessage = msg
- w.WriteHeader(code)
- t := template.Must(template.ParseFiles("PG/error.html"))
- t.Execute(w, data)
- }
|