Create basic server

Includes app config and some initialization
This commit is contained in:
Matt Baer
2018-10-15 14:44:15 -04:00
parent 343f67dc97
commit 16473c97b7
6 changed files with 233 additions and 0 deletions

31
routes.go Normal file
View File

@@ -0,0 +1,31 @@
package writefreely
import (
"github.com/gorilla/mux"
"github.com/writeas/web-core/log"
"github.com/writeas/writefreely/config"
"strings"
)
func initRoutes(handler *Handler, r *mux.Router, cfg *config.Config) {
isSingleUser := !cfg.App.MultiUser
// Write.as router
hostSubroute := cfg.Server.Host[strings.Index(cfg.Server.Host, "://")+3:]
if isSingleUser {
hostSubroute = "{domain}"
} else {
if strings.HasPrefix(hostSubroute, "localhost") {
hostSubroute = "localhost"
}
}
if isSingleUser {
log.Info("Adding %s routes (single user)...", hostSubroute)
return
}
// Primary app routes
log.Info("Adding %s routes (multi-user)...", hostSubroute)
}