Add NodeInfo endpoints

Includes new instance stats and the new option to show user stats, as
well.
This commit is contained in:
Matt Baer
2018-10-17 18:57:37 -04:00
parent 39477cfcab
commit 1a6f61690e
4 changed files with 104 additions and 0 deletions

View File

@@ -2,8 +2,10 @@ package writefreely
import (
"github.com/gorilla/mux"
"github.com/writeas/go-nodeinfo"
"github.com/writeas/web-core/log"
"github.com/writeas/writefreely/config"
"net/http"
"strings"
)
@@ -28,4 +30,12 @@ func initRoutes(handler *Handler, r *mux.Router, cfg *config.Config, db *datasto
// Primary app routes
log.Info("Adding %s routes (multi-user)...", hostSubroute)
write := r.Host(hostSubroute).Subrouter()
// Federation endpoints
// nodeinfo
niCfg := nodeInfoConfig(cfg)
ni := nodeinfo.NewService(*niCfg, nodeInfoResolver{cfg, db})
write.HandleFunc(nodeinfo.NodeInfoPath, handler.LogHandlerFunc(http.HandlerFunc(ni.NodeInfoDiscover)))
write.HandleFunc(niCfg.InfoURL, handler.LogHandlerFunc(http.HandlerFunc(ni.NodeInfo)))
}