Make the index page dynamic
This commit is contained in:
10
main.go
10
main.go
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user