|
|
|
@ -4,14 +4,14 @@ import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"go.goblog.app/app/pkgs/bufferpool"
|
|
|
|
|
"go.goblog.app/app/pkgs/contenttype"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (a *goBlog) serveNodeInfoDiscover(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
w.Header().Set(contentType, contenttype.JSONUTF8)
|
|
|
|
|
mw := a.min.Writer(contenttype.JSON, w)
|
|
|
|
|
defer mw.Close()
|
|
|
|
|
_ = json.NewEncoder(mw).Encode(map[string]interface{}{
|
|
|
|
|
buf := bufferpool.Get()
|
|
|
|
|
defer bufferpool.Put(buf)
|
|
|
|
|
err := json.NewEncoder(buf).Encode(map[string]interface{}{
|
|
|
|
|
"links": []map[string]interface{}{
|
|
|
|
|
{
|
|
|
|
|
"href": a.getFullAddress("/nodeinfo"),
|
|
|
|
@ -19,16 +19,23 @@ func (a *goBlog) serveNodeInfoDiscover(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
a.serveError(w, r, "", http.StatusInternalServerError)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
w.Header().Set(contentType, contenttype.JSONUTF8)
|
|
|
|
|
mw := a.min.Writer(contenttype.JSON, w)
|
|
|
|
|
_, _ = buf.WriteTo(mw)
|
|
|
|
|
_ = mw.Close()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *goBlog) serveNodeInfo(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
localPosts, _ := a.db.countPosts(&postsRequestConfig{
|
|
|
|
|
status: statusPublished,
|
|
|
|
|
})
|
|
|
|
|
mw := a.min.Writer(contenttype.JSON, w)
|
|
|
|
|
defer mw.Close()
|
|
|
|
|
w.Header().Set(contentType, contenttype.JSONUTF8)
|
|
|
|
|
_ = json.NewEncoder(mw).Encode(map[string]interface{}{
|
|
|
|
|
buf := bufferpool.Get()
|
|
|
|
|
defer bufferpool.Put(buf)
|
|
|
|
|
err := json.NewEncoder(buf).Encode(map[string]interface{}{
|
|
|
|
|
"version": "2.1",
|
|
|
|
|
"software": map[string]interface{}{
|
|
|
|
|
"name": "goblog",
|
|
|
|
@ -47,4 +54,12 @@ func (a *goBlog) serveNodeInfo(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
},
|
|
|
|
|
"metadata": map[string]interface{}{},
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
a.serveError(w, r, "", http.StatusInternalServerError)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
w.Header().Set(contentType, contenttype.JSONUTF8)
|
|
|
|
|
mw := a.min.Writer(contenttype.JSON, w)
|
|
|
|
|
_, _ = buf.WriteTo(mw)
|
|
|
|
|
_ = mw.Close()
|
|
|
|
|
}
|
|
|
|
|