mirror of
https://github.com/selfhst/icons.git
synced 2026-04-30 13:26:18 -04:00
v4.0.2 (Custom icon fix, root path info)
This commit is contained in:
@@ -1 +1 @@
|
||||
4.0.1
|
||||
4.0.2
|
||||
@@ -558,7 +558,17 @@ func handleCustomIcon(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
filename = strings.ToLower(filename)
|
||||
|
||||
customPath := filepath.Join(config.LocalPath, "custom", filename)
|
||||
actualFilename := filename
|
||||
if entries, err := os.ReadDir(filepath.Join(config.LocalPath, "custom")); err == nil {
|
||||
for _, entry := range entries {
|
||||
if strings.ToLower(entry.Name()) == filename {
|
||||
actualFilename = entry.Name()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
customPath := filepath.Join(config.LocalPath, "custom", actualFilename)
|
||||
|
||||
stat, err := os.Stat(customPath)
|
||||
if err != nil {
|
||||
@@ -633,6 +643,15 @@ func main() {
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
fmt.Fprintf(w, "selfh.st/icons\n\nEndpoints:\n GET /{iconname}\n GET /{iconname}/{colorcode}\n GET /custom/{filename}\n GET /health\n")
|
||||
})
|
||||
|
||||
mux.HandleFunc("GET /health", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
@@ -704,4 +723,4 @@ func main() {
|
||||
}
|
||||
|
||||
log.Println("Server stopped. Bye for now!")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user