2021-10-18 18:38:28 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-10-19 15:41:09 +00:00
|
|
|
"log"
|
2021-10-18 18:38:28 +00:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func setRoutes(mux *http.ServeMux) {
|
|
|
|
|
|
|
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if r.URL.Path != "/" {
|
|
|
|
http.NotFound(w, r)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
Files := []string{}
|
|
|
|
for file := range files {
|
|
|
|
Files = append(Files, files[file].Alias)
|
|
|
|
}
|
|
|
|
|
|
|
|
data := struct {
|
|
|
|
Active string
|
|
|
|
Files []string
|
|
|
|
Content string
|
|
|
|
Lang string
|
2021-10-19 15:41:09 +00:00
|
|
|
Error string
|
|
|
|
Editor struct {
|
|
|
|
RO bool
|
|
|
|
}
|
2021-10-18 18:38:28 +00:00
|
|
|
}{
|
2021-10-19 15:41:09 +00:00
|
|
|
Files: Files,
|
|
|
|
Editor: struct{ RO bool }{},
|
2021-10-18 18:38:28 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 15:41:09 +00:00
|
|
|
content := ""
|
|
|
|
name := r.URL.Query().Get("name")
|
|
|
|
file, ok := files[name]
|
|
|
|
if name == "" || !ok {
|
|
|
|
contentB, err := GetConfig()
|
|
|
|
if err != nil {
|
|
|
|
content = err.Error()
|
|
|
|
} else {
|
|
|
|
content = string(contentB)
|
|
|
|
}
|
|
|
|
if !ok {
|
|
|
|
data.Error = name + " not found"
|
|
|
|
}
|
|
|
|
data.Active = "ConfigUI"
|
|
|
|
}
|
|
|
|
log.Println(file)
|
|
|
|
|
|
|
|
data.Content = content
|
|
|
|
|
2021-10-19 04:34:01 +00:00
|
|
|
Parse(w, "home", data)
|
2021-10-18 18:38:28 +00:00
|
|
|
})
|
|
|
|
}
|