main.go 469 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. "pinguin/board"
  6. )
  7. func main() {
  8. //runtime.GOMAXPROCS(1)
  9. http.HandleFunc("/api/board", boardHandler)
  10. http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  11. w.Write([]byte("Go battlecamp!"))
  12. })
  13. log.Fatal(http.ListenAndServe(":8080", nil))
  14. }
  15. func boardHandler(w http.ResponseWriter, req *http.Request) {
  16. b := board.New(56, 35)
  17. w.Header().Set("Content-Type", "text/plain;charset=utf-8")
  18. b.WriteJSON(w)
  19. }