mirror of
https://github.com/writeas/writefreely
synced 2025-01-25 18:18:40 +01:00
0c1e1dd57e
This includes config changes, collections, posts, some post rendering funcs, and actual database connection when the server starts up.
32 lines
691 B
Go
32 lines
691 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, db *datastore) {
|
|
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)
|
|
}
|