Ejemplo n.º 1
0
func NewServerFromParams(Params *revel.Params) (server *Server) {
	server = &Server{
		Label:    Params.Get("label"),
		Username: Params.Get("username"),
		Host:     Params.Get("host"),
		Port:     Params.Get("port"),
	}
	queryInterval, err := strconv.Atoi(Params.Get("query_interval"))

	if err != nil {
		server.SetQueryInterval(60)
	} else {
		server.SetQueryInterval(queryInterval)
	}
	server.ParsePrivateKey(Params.Get("private_key"))
	server.SetPassword(Params.Get("password"))

	var cmds [][]string
	Params.Bind(&cmds, "commands")
	server.Commands = make(map[string]string)

	for _, cmd := range cmds {
		if len(cmd) == 2 && cmd[0] != "" && cmd[1] != "" {
			server.Commands[cmd[0]] = cmd[1]
		}
	}
	return
}
Ejemplo n.º 2
0
func bindCard(params *revel.Params, name string, typ reflect.Type) reflect.Value {
	var card models.Card
	if name == "card" && typ == reflect.TypeOf(card) {
		params.Bind(&card.CardBody, "CardBody")
		params.Bind(&card.CardBlanks, "CardBlanks")
		params.Bind(&card.CardType, "CardType")

		return reflect.ValueOf(card)
	}
	return reflect.ValueOf(nil)
}