func NewService(txn *cheshire.Txn) {
	log.Println(txn.Params())

	name, ok := txn.Params().GetString("service-name")
	if !ok {
		cheshire.Flash(txn, "error", "Service Name is manditory")
	}

	err := Servs.NewRouterTable(name, 512, 2)
	if err != nil {
		cheshire.Flash(txn, "error", fmt.Sprintf("%s", err))
	} else {
		cheshire.Flash(txn, "success", "successfully created router table")
	}
	cheshire.Redirect(txn, "/index")
}
Beispiel #2
0
//an example html page
func Index(txn *cheshire.Txn) {
	//create a context map to be passed to the template
	context := make(map[string]interface{})
	context["content"] = "Welcome to the wild(ing)!"

	//set a flash message
	cheshire.Flash(txn, "success", "this is a flash message!")

	//Render index template in layout
	cheshire.RenderInLayout(txn, "/public/index.html", "/layouts/base.html", context)
}
func Service(txn *cheshire.Txn) {
	//create a context map to be passed to the template
	context := make(map[string]interface{})

	service, ok := Servs.RouterTable(txn.Params().MustString("service", ""))
	context["service"] = service
	if !ok {
		cheshire.Flash(txn, "error", fmt.Sprintf("Cant find service"))
		cheshire.Redirect(txn, "/index")
		return
	}
	cheshire.RenderInLayout(txn, "/router_table.html", "/template.html", context)
}