1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

removed old API

This commit is contained in:
Harvey Kandola 2017-08-02 15:26:31 +01:00
parent e284a46f86
commit 562872a4a8
105 changed files with 337 additions and 14496 deletions

View file

@ -166,5 +166,7 @@ func RegisterEndpoints(rt *env.Runtime, s *domain.Store) {
Add(rt, RoutePrefixRoot, "robots.txt", []string{"GET", "OPTIONS"}, nil, meta.RobotsTxt)
Add(rt, RoutePrefixRoot, "sitemap.xml", []string{"GET", "OPTIONS"}, nil, meta.Sitemap)
Add(rt, RoutePrefixRoot, "{rest:.*}", nil, nil, web.EmberHandler)
webHandler := web.Handler{Runtime: rt, Store: s}
Add(rt, RoutePrefixRoot, "{rest:.*}", nil, nil, webHandler.EmberHandler)
}

View file

@ -18,7 +18,6 @@ import (
"strings"
"github.com/codegangsta/negroni"
"github.com/documize/community/core/api/endpoint"
"github.com/documize/community/core/api/plugins"
"github.com/documize/community/core/database"
"github.com/documize/community/core/env"
@ -32,7 +31,7 @@ var testHost string // used during automated testing
// Start router to handle all HTTP traffic.
func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
err := plugins.LibSetup()
err := plugins.Setup(s)
if err != nil {
rt.Log.Error("Terminating before running - invalid plugin.json", err)
os.Exit(1)
@ -45,7 +44,8 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
case env.SiteModeOffline:
rt.Log.Info("Serving OFFLINE web server")
case env.SiteModeSetup:
routing.Add(rt, routing.RoutePrefixPrivate, "setup", []string{"POST", "OPTIONS"}, nil, database.Create)
dbHandler := database.Handler{Runtime: rt, Store: s}
routing.Add(rt, routing.RoutePrefixPrivate, "setup", []string{"POST", "OPTIONS"}, nil, dbHandler.Create)
rt.Log.Info("Serving SETUP web server")
case env.SiteModeBadDB:
rt.Log.Info("Serving BAD DATABASE web server")
@ -70,7 +70,7 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
// "/api/..."
router.PathPrefix(routing.RoutePrefixPrivate).Handler(negroni.New(
negroni.HandlerFunc(endpoint.Authorize),
negroni.HandlerFunc(cm.Authorize),
negroni.Wrap(routing.BuildRoutes(rt, routing.RoutePrefixPrivate)),
))

View file

@ -16,9 +16,9 @@ import (
"html/template"
"net/http"
"github.com/documize/community/core/api"
"github.com/documize/community/core/env"
"github.com/documize/community/core/secrets"
"github.com/documize/community/domain"
)
// SiteInfo describes set-up information about the site
@ -30,10 +30,16 @@ func init() {
SiteInfo.DBhash = secrets.GenerateRandomPassword() // do this only once
}
// Handler contains the runtime information such as logging and database.
type Handler struct {
Runtime *env.Runtime
Store *domain.Store
}
// EmberHandler serves HTML web pages
func EmberHandler(w http.ResponseWriter, r *http.Request) {
func (h *Handler) EmberHandler(w http.ResponseWriter, r *http.Request) {
filename := "index.html"
switch api.Runtime.Flags.SiteMode {
switch h.Runtime.Flags.SiteMode {
case env.SiteModeOffline:
filename = "offline.html"
case env.SiteModeSetup: