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
+36
View File
@@ -0,0 +1,36 @@
// Copyright 2015 Claudemiro Alves Feitosa Neto. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package ipe
import (
"encoding/json"
"io/ioutil"
"net/http"
)
// Conf holds the global configuration state
var Conf ConfigFile
// Start Parse the configuration file and starts the ipe server
func Start(configfile string) error {
file, err := ioutil.ReadFile(configfile)
if err != nil {
return err
}
if err := json.Unmarshal(file, &Conf); err != nil {
return err
}
Conf.Init()
router := NewRouter()
if err := http.ListenAndServe(Conf.Host, router); err != nil {
return err
}
return nil
}