mirror of
https://github.com/writefreely/writefreely
synced 2024-11-28 19:40:17 +00:00
16473c97b7
Includes app config and some initialization
31 lines
676 B
Go
31 lines
676 B
Go
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)
|
|
}
|