mirror of
https://github.com/jlelse/GoBlog
synced 2024-06-14 13:37:10 +00:00
Add category query
This commit is contained in:
parent
1e9f97cb2f
commit
0cb142bd20
15
micropub.go
15
micropub.go
|
@ -65,6 +65,21 @@ func serveMicropubQuery(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Add(contentType, contentTypeJSONUTF8)
|
w.Header().Add(contentType, contentTypeJSONUTF8)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_ = json.NewEncoder(w).Encode(mf)
|
_ = json.NewEncoder(w).Encode(mf)
|
||||||
|
case "category":
|
||||||
|
allCategories := []string{}
|
||||||
|
for blog := range appConfig.Blogs {
|
||||||
|
values, err := allTaxonomyValues(blog, appConfig.Micropub.CategoryParam)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
allCategories = append(allCategories, values...)
|
||||||
|
}
|
||||||
|
w.Header().Add(contentType, contentTypeJSONUTF8)
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
||||||
|
"categories": allCategories,
|
||||||
|
})
|
||||||
default:
|
default:
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user