File structure organization.

Create a new package ipe and put everything n there except for the main function.
This commit is contained in:
claudemiro
2015-01-31 08:29:01 -03:00
parent c7f757e517
commit cd1fd8995d
22 changed files with 59 additions and 42 deletions
+5 -24
View File
@@ -5,45 +5,26 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
"github.com/dimiro1/ipe/ipe"
log "github.com/golang/glog"
)
var Conf ConfigFile
// Main function, initialze the system
func main() {
printBanner()
var filename = flag.String("config", "config.json", "Config file location")
flag.Parse()
file, err := ioutil.ReadFile(*filename)
printBanner()
if err != nil {
log.Fatal(err)
}
if err := json.Unmarshal(file, &Conf); err != nil {
log.Fatal(err)
}
Conf.Init()
router := NewRouter()
log.Infof("Starting Ipê using config file: '%s'", *filename)
if err := http.ListenAndServe(Conf.Host, router); err != nil {
if err := ipe.Start(*filename); err != nil {
log.Fatal(err)
}
}
// Print a beatifull banner
func printBanner() {
fmt.Print("\033[36m")
fmt.Print(`