Add demo project

This commit is contained in:
2015-08-29 19:58:24 +03:00
parent 2dc27e62c5
commit abe48658a3
4 changed files with 61 additions and 1 deletions
+12
View File
@@ -0,0 +1,12 @@
{
"app_name": "Awesome App",
"version": 1.4,
"debug": true,
"database": {
"adapter": "mysql",
"host": "127.0.0.1",
"port": 3306,
"username": "root",
"password": ""
}
}
+47
View File
@@ -0,0 +1,47 @@
package main
import (
"flag"
"log"
"github.com/localhots/secondly"
)
// testConf is our app's configuration
type testConf struct {
AppName string `json:"app_name"`
Version float32 `json:"version"`
Debug bool `json:"debug"`
Database testDatabaseConf `json:"database"`
}
type testDatabaseConf struct {
Adapter string `json:"adapter"`
Host string `json:"host"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
}
// conf is the variable that holds configuration
var conf = testConf{}
func main() {
// Setting up flags
secondly.SetupFlags()
flag.Parse()
// Delegating configuration management to Secondly
secondly.Manage(&conf)
// Handling file system events
secondly.HandleFSEvents()
// Starting a web server
secondly.StartServer("", 5500)
// Defining callbacks
secondly.OnChange("AppName", func(o, n interface{}) {
log.Printf("OMG! AppName changed from %q to %q", o, n)
})
// Other application startup logic
select {}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB