Bläddra i källkod

path config seperated to stand alone file.

master
Patrick Peng Sun 8 år sedan
förälder
incheckning
d48611054e
5 ändrade filer med 56 tillägg och 14 borttagningar
  1. +1
    -1
      common_test.go
  2. +3
    -0
      config.go
  3. +41
    -0
      configPath.go
  4. +6
    -13
      main.go
  5. +5
    -0
      path_config.json

+ 1
- 1
common_test.go Visa fil

IntraAPIConfig = ConfigIntraAPI{ IntraAPIConfig = ConfigIntraAPI{
"cAT/ckkfjajvczxiaufodqdfakpozcczfas341fda.vfasdk/8934125", "cAT/ckkfjajvczxiaufodqdfakpozcczfas341fda.vfasdk/8934125",
} }
GlobalPath = PathsConfig{"/tmp", "spa/"}
GlobalPath = PathsConfig{"/tmp", "spa/", "http://192.168.1.39:65500/"}
KFUsers.kfRenewList() KFUsers.kfRenewList()
} }



+ 3
- 0
config.go Visa fil

copy(k[:], key) copy(k[:], key)
return k return k
} }




+ 41
- 0
configPath.go Visa fil

package main

import (
"encoding/json"
"errors"
"io/ioutil"
"log"
)

//PathsConfig all system available pathes
type PathsConfig struct {
Angular2App string `json:"angular2_app"`
SinglePageEdit string `json:"singlePageEdit"`
ThisSiteURL string `json:"thisSiteURL"`
}

//GlobalPath all global pathes configurations
var GlobalPath = PathsConfig{}

func (m *PathsConfig) readConfig() error {
log.Printf("read Path config from %s\r\n", "path_config.json")
body, err := ioutil.ReadFile("path_config.json")
if err != nil {
log.Fatal("Cannot read config from path_config.json")
return err
}
err = json.Unmarshal(body, m)
if m.SinglePageEdit == "" {
return errors.New("Single Page Edit Resources not available")
}

if m.Angular2App == "" {
return errors.New("Angular2APP path not available")
}

if m.ThisSiteURL == "" {
return errors.New("site url not available")
}

return err
}

+ 6
- 13
main.go Visa fil

"time" "time"
) )


//PathsConfig all system available pathes
type PathsConfig struct {
Angular2App string `json:"angular2_app"`
SinglePageEdit string `json:"singlePageEdit"`
}

//GlobalPath all global pathes configurations
// TODO: setup GlobalPath Config, from reading file
var GlobalPath = PathsConfig{
"dist/",
"spa/",
}

//KFUsers info cache about current customer service //KFUsers info cache about current customer service
var KFUsers kfCache var KFUsers kfCache


log.Fatal("unable to read intra-api-config, program quit") log.Fatal("unable to read intra-api-config, program quit")
} }


err = GlobalPath.readConfig()
if err != nil {
log.Println(err)
log.Fatal("unable to read globalPath, program quit")
}

initAllProc() initAllProc()
setupRootFileServer() setupRootFileServer()
startSessionManager(2048) startSessionManager(2048)

+ 5
- 0
path_config.json Visa fil

{
"angular2_app" : "dist/",
"singlePageEdit" : "spa/",
"thisSiteURL" :"http://192.168.1.39:65500/"
}

Laddar…
Avbryt
Spara