func NewFunServant(cf *config.ConfigServant) (this *FunServantImpl) { this = &FunServantImpl{ conf: cf, digitNormalizer: regexp.MustCompile(`\d+`), proxyMode: config.Engine.IsProxyOnly(), } // http REST to export internal state server.RegisterHttpApi("/svt/{cmd}", func(w http.ResponseWriter, req *http.Request, params map[string]interface{}) (interface{}, error) { return this.handleHttpQuery(w, req, params) }).Methods("GET") this.sessions = cache.NewLruCache(cf.SessionMaxItems) this.mysqlMergeMutexMap = mutexmap.New(cf.Mysql.JsonMergeMaxOutstandingItems) this.ctxReasonPercentage = metrics.NewPercentCounter() metrics.Register("call.reason", this.ctxReasonPercentage) this.dbCacheHits = metrics.NewPercentCounter() metrics.Register("db.cache.hits", this.dbCacheHits) this.createServants() return }
func (this *Engine) launchHttpServ() { if config.Engine.HttpListenAddr == "" { return } server.LaunchHttpServer(config.Engine.HttpListenAddr, config.Engine.PprofListenAddr) server.RegisterHttpApi("/h", func(w http.ResponseWriter, req *http.Request, params map[string]interface{}) (interface{}, error) { return this.handleHttpHelpQuery(w, req, params) }).Methods("GET") server.RegisterHttpApi("/help", func(w http.ResponseWriter, req *http.Request, params map[string]interface{}) (interface{}, error) { return this.handleHttpHelpQuery(w, req, params) }).Methods("GET") server.RegisterHttpApi("/engine/{cmd}", func(w http.ResponseWriter, req *http.Request, params map[string]interface{}) (interface{}, error) { return this.handleHttpQuery(w, req, params) }).Methods("GET") }