GoBlog/nodeinfo.go

47 lines
1.1 KiB
Go
Raw Normal View History

2020-11-17 16:10:14 +00:00
package main
2021-01-21 16:59:47 +00:00
import (
"encoding/json"
"net/http"
2020-11-17 16:10:14 +00:00
)
2021-01-21 16:59:47 +00:00
func serveNodeInfoDiscover(w http.ResponseWriter, r *http.Request) {
w.Header().Set(contentType, contentTypeJSONUTF8)
nid := map[string]interface{}{
"links": []map[string]interface{}{
{
"href": appConfig.Server.PublicAddress + "/nodeinfo",
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.1",
2020-11-17 16:10:14 +00:00
},
},
}
2021-01-21 16:59:47 +00:00
_ = json.NewEncoder(w).Encode(&nid)
2020-11-17 16:10:14 +00:00
}
2021-01-21 16:59:47 +00:00
func serveNodeInfo(w http.ResponseWriter, r *http.Request) {
w.Header().Set(contentType, contentTypeJSONUTF8)
localPosts, _ := countPosts(&postsRequestConfig{
2021-01-15 20:56:46 +00:00
status: statusPublished,
})
2021-01-21 16:59:47 +00:00
nid := map[string]interface{}{
"version": "2.1",
"software": map[string]interface{}{
"name": "goblog",
"repository": "https://git.jlel.se/jlelse/GoBlog",
},
"usage": map[string]interface{}{
"users": map[string]interface{}{
"total": len(appConfig.Blogs),
},
"localPosts": localPosts,
},
"protocols": []string{
"activitypub",
"micropub",
"webmention",
2020-11-17 16:10:14 +00:00
},
2021-01-21 16:59:47 +00:00
"metadata": map[string]interface{}{},
2020-11-17 16:10:14 +00:00
}
2021-01-21 16:59:47 +00:00
_ = json.NewEncoder(w).Encode(&nid)
2020-11-17 16:10:14 +00:00
}