main.go 629 B

123456789101112131415161718192021222324
  1. package main
  2. import (
  3. "battlecamp-go-server/board"
  4. "log"
  5. "net/http"
  6. "strconv"
  7. )
  8. func main() {
  9. http.HandleFunc("", generateBoard)
  10. log.Fatal(http.ListenAndServe(":8081", nil))
  11. }
  12. func generateBoard(w http.ResponseWriter, r *http.Request) {
  13. x, _ := strconv.Atoi(r.FormValue("x"))
  14. y, _ := strconv.Atoi(r.FormValue("y"))
  15. width, _ := strconv.Atoi(r.FormValue("width"))
  16. height, _ := strconv.Atoi(r.FormValue("height"))
  17. totalWidth, _ := strconv.Atoi(r.FormValue("totalWidth"))
  18. totalHeight, _ := strconv.Atoi(r.FormValue("totalHeight"))
  19. b := board.NewPartial(x, y, width, height, totalWidth, totalHeight)
  20. b.WriteData(w)
  21. }