Browse Source

Move Host config value from Server -> App

tags/v0.1.0
Matt Baer 5 years ago
parent
commit
e6f1291189
5 changed files with 7 additions and 8 deletions
  1. +2
    -2
      config/config.go
  2. +2
    -2
      config/setup.go
  3. +1
    -1
      nodeinfo.go
  4. +1
    -2
      routes.go
  5. +1
    -1
      session.go

+ 2
- 2
config/config.go View File

@@ -10,7 +10,6 @@ const (

type (
ServerCfg struct {
Host string `ini:"host"`
Port int `ini:"port"`
}

@@ -25,6 +24,7 @@ type (

AppCfg struct {
SiteName string `ini:"site_name"`
Host string `ini:"host"`

// Site appearance
Theme string `ini:"theme"`
@@ -52,7 +52,6 @@ type (
func New() *Config {
return &Config{
Server: ServerCfg{
Host: "http://localhost:8080",
Port: 8080,
},
Database: DatabaseCfg{
@@ -61,6 +60,7 @@ func New() *Config {
Port: 3306,
},
App: AppCfg{
Host: "http://localhost:8080",
Theme: "write",
WebFonts: true,
SingleUser: true,


+ 2
- 2
config/setup.go View File

@@ -42,9 +42,9 @@ func Configure() error {
prompt = promptui.Prompt{
Label: "Public-facing host",
Validate: validateDomain,
Default: c.Server.Host,
Default: c.App.Host,
}
c.Server.Host, err = prompt.Run()
c.App.Host, err = prompt.Run()
if err != nil {
return err
}


+ 1
- 1
nodeinfo.go View File

@@ -15,7 +15,7 @@ type nodeInfoResolver struct {
func nodeInfoConfig(cfg *config.Config) *nodeinfo.Config {
name := cfg.App.SiteName
return &nodeinfo.Config{
BaseURL: cfg.Server.Host,
BaseURL: cfg.App.Host,
InfoURL: "/api/nodeinfo",

Metadata: nodeinfo.Metadata{


+ 1
- 2
routes.go View File

@@ -12,8 +12,7 @@ import (
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:]
hostSubroute := cfg.App.Host[strings.Index(cfg.App.Host, "://")+3:]
if isSingleUser {
hostSubroute = "{domain}"
} else {


+ 1
- 1
session.go View File

@@ -27,7 +27,7 @@ func initSession(app *app) *sessions.CookieStore {
Path: "/",
MaxAge: sessionLength,
HttpOnly: true,
Secure: strings.HasPrefix(app.cfg.Server.Host, "https://"),
Secure: strings.HasPrefix(app.cfg.App.Host, "https://"),
}
return store
}


Loading…
Cancel
Save