diff --git a/bin/main.go b/bin/main.go index 19b7668..649f75f 100644 --- a/bin/main.go +++ b/bin/main.go @@ -34,10 +34,10 @@ func main() { var mysqlConnection models.MysqlConnection mysqlConnection.Init() - // URL 格式: /img/{type}/{id}.{format}?width=320&height=320&fit=cover + // URL 格式: /img/{type}-{id}.{format}?width=320&height=320&fit=cover http.HandleFunc("/img/", func(w http.ResponseWriter, r *http.Request) { log.Println(r.Method, r.URL.Path) - reg := regexp.MustCompile(`^/img/([0-9a-zA-Z]+)/([0-9a-zA-Z]+).(jpg|jpeg|png|webp)$`) + reg := regexp.MustCompile(`^/img/([0-9a-zA-Z]+)-([0-9a-zA-Z]+).(jpg|jpeg|png|webp)$`) matches := reg.FindStringSubmatch(r.URL.Path) if len(matches) != 4 { log.Println("URL 格式错误", matches) @@ -70,7 +70,7 @@ func main() { log.Println(r.Method, r.URL.Path) reg := regexp.MustCompile(`^/webp/([0-9a-zA-Z]+)-([0-9a-zA-Z]+)-([0-9a-zA-Z]+)-([0-9]+)-([0-9]+)-([a-zA-Z]+).(jpg|jpeg|png|webp)$`) matches := reg.FindStringSubmatch(r.URL.Path) - if len(matches) != 4 { + if len(matches) != 8 { log.Println("URL 格式错误", matches) w.WriteHeader(http.StatusNotFound) return diff --git a/main b/main deleted file mode 100755 index c34bbcc..0000000 Binary files a/main and /dev/null differ