| LeanWork struct { | LeanWork struct { | ||||
| MD5Key string `json:MD5Key` | MD5Key string `json:MD5Key` | ||||
| } `json:LeanWork` | } `json:LeanWork` | ||||
| DB struct { | |||||
| Driver string `json:Driver` | |||||
| User string `json:User` | |||||
| Pass string `json:Pass` | |||||
| Schema string `json:Schema` | |||||
| } `json:DB` | |||||
| } | } | ||||
| var Config AppConfig | var Config AppConfig |
| }, | }, | ||||
| "LeanWork" :{ | "LeanWork" :{ | ||||
| "MD5Key" : "492815086935204" | "MD5Key" : "492815086935204" | ||||
| } | |||||
| }, | |||||
| "DB" :{ | |||||
| "Driver": "mysql", | |||||
| "User" : "sp", | |||||
| "Pass" : "sp", | |||||
| "Schema": "goblog" | |||||
| } | |||||
| } | } |
| }, | }, | ||||
| "LeanWork" :{ | "LeanWork" :{ | ||||
| "MD5Key" : "492815086935204" | "MD5Key" : "492815086935204" | ||||
| }, | |||||
| "DB" :{ | |||||
| "Driver": "mysql", | |||||
| "User" : "sp", | |||||
| "Pass" : "sp", | |||||
| "Schema": "goblog" | |||||
| } | } | ||||
| } | } |
| "log" | "log" | ||||
| "net/http" | "net/http" | ||||
| "text/template" | "text/template" | ||||
| _ "github.com/go-sql-driver/mysql" | |||||
| ) | ) | ||||
| type Employee struct { | type Employee struct { | ||||
| } | } | ||||
| func dbConn() (db *sql.DB) { | func dbConn() (db *sql.DB) { | ||||
| dbDriver := "mysql" | |||||
| dbUser := "sp" | |||||
| dbPass := "sp" | |||||
| dbName := "goblog" | |||||
| dbDriver := Config.DB.Driver | |||||
| dbUser := Config.DB.User | |||||
| dbPass := Config.DB.Pass | |||||
| dbName := Config.DB.Schema | |||||
| db, err := sql.Open(dbDriver, dbUser+":"+dbPass+"@/"+dbName) | db, err := sql.Open(dbDriver, dbUser+":"+dbPass+"@/"+dbName) | ||||
| if err != nil { | if err != nil { | ||||
| panic(err.Error()) | panic(err.Error()) |
| import ( | import ( | ||||
| "log" | "log" | ||||
| "net/http" | "net/http" | ||||
| _ "github.com/go-sql-driver/mysql" | |||||
| ) | ) | ||||
| func main() { | func main() { | ||||
| readConfig() | readConfig() | ||||
| log.Println("Server started on: http://localhost:8080") | log.Println("Server started on: http://localhost:8080") | ||||
| http.HandleFunc("/", StartPay) | |||||
| //http.HandleFunc("/", StartPay) | |||||
| //http.HandleFunc("/", Index) | |||||
| // http.HandleFunc("/show", Show) | |||||
| // http.HandleFunc("/new", New) | |||||
| // http.HandleFunc("/edit", Edit) | |||||
| // http.HandleFunc("/insert", Insert) | |||||
| // http.HandleFunc("/update", Update) | |||||
| // http.HandleFunc("/delete", Delete) | |||||
| http.HandleFunc("/", Index) | |||||
| http.HandleFunc("/show", Show) | |||||
| http.HandleFunc("/new", New) | |||||
| http.HandleFunc("/edit", Edit) | |||||
| http.HandleFunc("/insert", Insert) | |||||
| http.HandleFunc("/update", Update) | |||||
| http.HandleFunc("/delete", Delete) | |||||
| http.ListenAndServe(":8080", nil) | http.ListenAndServe(":8080", nil) | ||||
| } | } |
| func StartPay(w http.ResponseWriter, r *http.Request) { | func StartPay(w http.ResponseWriter, r *http.Request) { | ||||
| if r.Method != "POST" { | if r.Method != "POST" { | ||||
| fmt.Fprintf(w, "fuck") | |||||
| fmt.Fprintf(w, "invalid request") | |||||
| return | return | ||||
| } | } | ||||
| r.ParseForm() | r.ParseForm() |