Example #1
0
func init() {
	revel.OnAppStart(func() {
		ServersMap, ServersLastError = models.LoadServers()
		if ServersLastError != nil {
			revel.ERROR.Print(ServersLastError)
		}
	})
}
Example #2
0
func (self *ApiServers) All () revel.Result {

	if	ServersLastError != nil	{
		var result	= map [ string ] interface{} { "error2" : ServersLastError, "error" : "a" }
		return	self.RenderJson ( result )
	}

	var	action	= strings.ToLower ( self.Params.Get ( "action" ) )
	switch	action	{
		case "save"	:
			ServersMap.Save ()
		case "reload"	:
			for	_, s	:= range ( * ServersMap )	{
				s.Delete ()
			}
			ServersMap, ServersLastError	= models .LoadServers ()
			if	ServersLastError != nil	{
				revel.ERROR.Print ( ServersLastError )
			}
	}

	PerformActions ( self.Params, ServersMap )
	return	self.RenderJson ( ServersMap )
}