|
|
@@ -4,6 +4,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"io/fs"
|
|
|
"net/http"
|
|
|
+ "os"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
@@ -16,7 +17,7 @@ type LoginResp struct {
|
|
|
Success bool `json:"success"`
|
|
|
}
|
|
|
|
|
|
-func WebLoginHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func loginHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method != http.MethodPost {
|
|
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
|
|
return
|
|
|
@@ -47,7 +48,7 @@ func WebLoginHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
json.NewEncoder(w).Encode(LoginResp{Success: ok})
|
|
|
}
|
|
|
|
|
|
-func WebLogoutHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func logoutHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
if cookie, err := r.Cookie("session_id"); err == nil {
|
|
|
sessionMu.Lock()
|
|
|
delete(sessions, cookie.Value)
|
|
|
@@ -64,7 +65,12 @@ func WebLogoutHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
http.Redirect(w, r, "/", http.StatusFound)
|
|
|
}
|
|
|
|
|
|
-func (ui *WebUI) WebRootHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func getIMEIHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+ data, _ := os.ReadFile("/var/device_imei.txt")
|
|
|
+ w.Write(data)
|
|
|
+}
|
|
|
+
|
|
|
+func (ui *WebUI) rootHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
path := r.URL.Path
|
|
|
|
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|