Example #1
3
func (self *ApiServers) All() revel.Result {
	var action = strings.ToLower(self.Params.Get("action"))
	switch action {
	case "save":
		ServersLastError = ServersMap.Save()

	case "reload":
		if ServersLastError != nil {
			return self.RenderJson(GenerateJsonStruct("", ServersLastError.Error()))
		}
		for _, s := range *ServersMap {
			s.Delete()
		}
		ServersMap, ServersLastError = models.LoadServers()
	}
	if ServersLastError != nil {
		revel.ERROR.Print(ServersLastError)
		return self.RenderJson(GenerateJsonStruct("", ServersLastError.Error()))
	}

	PerformActions(self.Params, ServersMap)
	return self.RenderJson(ServersMap)
}
Example #2
2
func init() {
	revel.InterceptFunc(CheckUserAuth, revel.BEFORE, revel.ALL_CONTROLLERS)

	revel.OnAppStart(func() {
		ServersMap, ServersLastError = models.LoadServers()
		if ServersLastError != nil {
			revel.ERROR.Print(ServersLastError)
		}
	})
}