mirror of https://gitee.com/godoos/godoos.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
760 B
33 lines
760 B
package localchat
|
|
|
|
import (
|
|
"encoding/json"
|
|
"godo/libs"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func HandleCheck(w http.ResponseWriter, r *http.Request) {
|
|
hostname, err := os.Hostname()
|
|
if err != nil {
|
|
libs.ErrorMsg(w, "HandleMessage error")
|
|
return
|
|
}
|
|
libs.SuccessMsg(w, hostname, "")
|
|
}
|
|
func HandleAddr(w http.ResponseWriter, r *http.Request) {
|
|
var ipStr libs.UserChatIpSetting
|
|
err := json.NewDecoder(r.Body).Decode(&ipStr)
|
|
if err != nil {
|
|
libs.HTTPError(w, http.StatusBadRequest, "Failed to parse request body")
|
|
return
|
|
}
|
|
libs.SetConfigByName("ChatIpSetting", ipStr)
|
|
go CheckOnline()
|
|
libs.SuccessMsg(w, nil, "success")
|
|
}
|
|
|
|
func HandleGetAddr(w http.ResponseWriter, r *http.Request) {
|
|
ipInfo := libs.GetChatIpSetting()
|
|
libs.SuccessMsg(w, ipInfo, "success")
|
|
}
|
|
|