web.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. )
  6. func webServer(Dir string, ImgDir string, Port string) {
  7. fs := http.FileServer(http.Dir(Dir))
  8. http.Handle("/", fs)
  9. http.Handle("/skin/", http.StripPrefix("/skin/", http.FileServer(http.Dir(ImgDir+"/skin/"))))
  10. //CORE FUNCTION
  11. http.HandleFunc("/start", StartMCServer)
  12. http.HandleFunc("/stop", StopMCServer)
  13. http.HandleFunc("/kill", KillMCServer)
  14. http.HandleFunc("/restart", RestartMCServer)
  15. http.HandleFunc("/kickall", KickAllMCServer)
  16. //SYSTEM FUNCTION
  17. http.HandleFunc("/sendcommand", SendCommand)
  18. http.HandleFunc("/serverinfo", ServerInfo)
  19. http.HandleFunc("/log", ReadLog)
  20. http.HandleFunc("/log/from", ReadLogFrom)
  21. http.HandleFunc("/ban-ip", ReadBanIP)
  22. http.HandleFunc("/ban-player", ReadBanPlayer)
  23. http.HandleFunc("/eula", ReadEULA)
  24. http.HandleFunc("/ops", ReadOps)
  25. http.HandleFunc("/properties", ReadProperties)
  26. http.HandleFunc("/whitelist", ReadWhitelist)
  27. /*
  28. //EDIT
  29. http.HandleFunc("/eula/change", ChangeEULA)
  30. http.HandleFunc("/properties/change", ChangeProperties)
  31. //ADD
  32. http.HandleFunc("/ban-ip/add", AddBanIP)
  33. http.HandleFunc("/ban-player/add", AddBanPlayer)
  34. http.HandleFunc("/ops/add", AddOps)
  35. http.HandleFunc("/whitelist/add", AddWhitelist)
  36. //REMOVE
  37. http.HandleFunc("/ban-ip/remove", RemoveBanIP)
  38. http.HandleFunc("/ban-player/remove", RemoveBanPlayer)
  39. http.HandleFunc("/ops/remove", RemoveOps)
  40. http.HandleFunc("/whitelist/remove", RemoveWhitelist)
  41. */
  42. err := http.ListenAndServe(":"+Port, nil)
  43. if err != nil {
  44. log.Fatal(err)
  45. }
  46. }