package main

import (
	"log"
	"net/http"
)

func webServer(Dir string, Port string) {
	fs := http.FileServer(http.Dir(Dir))
	http.Handle("/", fs)

	//CORE FUNCTION
	http.HandleFunc("/start", StartMCServer)
	http.HandleFunc("/stop", StopMCServer)
	http.HandleFunc("/kill", KillMCServer)
	http.HandleFunc("/restart", RestartMCServer)
	http.HandleFunc("/kickall", KickAllMCServer)

	//SYSTEM FUNCTION
	http.HandleFunc("/log", ReadLog)
	http.HandleFunc("/ban-ip", ReadBanIP)
	http.HandleFunc("/ban-player", ReadBanPlayer)
	http.HandleFunc("/eula", ReadEULA)
	http.HandleFunc("/ops", ReadOps)
	http.HandleFunc("/properties", ReadProperties)
	http.HandleFunc("/whitelist", ReadWhitelist)

	//EDIT
	http.HandleFunc("/eula/change", ChangeEULA)
	http.HandleFunc("/properties/change", ChangeProperties)

	//ADD
	http.HandleFunc("/ban-ip/add", AddBanIP)
	http.HandleFunc("/ban-player/add", AddBanPlayer)
	http.HandleFunc("/ops/add", AddOps)
	http.HandleFunc("/whitelist/add", AddWhitelist)

	//REMOVE
	http.HandleFunc("/ban-ip/remove", RemoveBanIP)
	http.HandleFunc("/ban-player/remove", RemoveBanPlayer)
	http.HandleFunc("/ops/remove", RemoveOps)
	http.HandleFunc("/whitelist/remove", RemoveWhitelist)

	err := http.ListenAndServe(":"+Port, nil)
	if err != nil {
		log.Fatal(err)
	}
}
