11package main
22
33import (
4+ "encoding/json"
45 "fmt"
56 "io/ioutil"
67 "net/http"
78
8- "encoding/json"
99 log "github.com/Sirupsen/logrus"
10+ "github.com/codegangsta/negroni"
1011 "github.com/go-zoo/bone"
12+ "github.com/meatballhat/negroni-logrus"
1113)
1214
1315// jsonResponse struct encapsulates payload data
@@ -24,6 +26,22 @@ type messageResponse struct {
2426 Message string `json:"message"`
2527}
2628
29+ func (d * DBClient ) startAdminInterface () {
30+ // starting admin interface
31+ mux := getBoneRouter (* d )
32+ n := negroni .Classic ()
33+ n .Use (negronilogrus .NewMiddleware ())
34+ n .UseHandler (mux )
35+
36+ // admin interface starting message
37+ log .WithFields (log.Fields {
38+ "RedisAddress" : AppConfig .redisAddress ,
39+ "AdminPort" : AppConfig .adminInterface ,
40+ }).Info ("Admin interface is starting..." )
41+
42+ n .Run (AppConfig .adminInterface )
43+ }
44+
2745// getBoneRouter returns mux for admin interface
2846func getBoneRouter (d DBClient ) * bone.Mux {
2947 mux := bone .New ()
@@ -35,6 +53,8 @@ func getBoneRouter(d DBClient) *bone.Mux {
3553 mux .Get ("/state" , http .HandlerFunc (d .CurrentStateHandler ))
3654 mux .Post ("/state" , http .HandlerFunc (d .stateHandler ))
3755
56+ mux .Handle ("/*" , http .FileServer (http .Dir ("static" )))
57+
3858 return mux
3959}
4060
0 commit comments