Make the index page dynamic

This commit is contained in:
2021-09-26 12:33:31 +09:30
parent a99f65918f
commit 2c57a77b98
2 changed files with 38 additions and 12 deletions

10
main.go
View File

@@ -81,7 +81,8 @@ func main() {
r := mux.NewRouter()
r.HandleFunc("/", HomeHandler)
r.HandleFunc("/fetch", FetchHandler)
r.HandleFunc("/fetch/info/{id}", FetchInfoHandler)
r.HandleFunc("/fetch/info", FetchInfoHandler)
r.HandleFunc("/fetch/info/{id}", FetchInfoOneHandler)
http.Handle("/", r)
@@ -126,7 +127,7 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) {
}
func FetchInfoHandler(w http.ResponseWriter, r *http.Request) {
func FetchInfoOneHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
idString := vars["id"]
if idString != "" {
@@ -148,6 +149,11 @@ func FetchInfoHandler(w http.ResponseWriter, r *http.Request) {
}
}
func FetchInfoHandler(w http.ResponseWriter, r *http.Request) {
b, _ := json.Marshal(downloads)
w.Write(b)
}
func FetchHandler(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()