// Only the powerfull have access to the admin routes
func authenticate(ctx *weavebox.Context) error {
	admins := []string{"toby", "master iy", "c.froome"}
	name := ctx.Param("name")

	for _, admin := range admins {
		if admin == name {
			return nil
		}
	}
	return errors.New("access forbidden")
}
func helloHandler(ctx *weavebox.Context) error {
	return ctx.Text(http.StatusOK, "Hellos you v25")
}
func renderUserDetail(ctx *weavebox.Context) error {
	username := "******"
	return ctx.Render("user/index.html", username)
}
func renderIndex(ctx *weavebox.Context) error {
	return ctx.Render("index.html", nil)
}
// custom centralized error handling
func errorHandler(ctx *weavebox.Context, err error) {
	http.Error(ctx.Response(), "Hey some error occured: "+err.Error(), http.StatusInternalServerError)
}
func adminGreetingHandler(ctx *weavebox.Context) error {
	name := ctx.Param("name")
	db := datastoreFromContext(ctx.Context)
	greeting := fmt.Sprintf("Greetings powerfull admin, %s\nYour database %s is ready", name, db.name)
	return ctx.Text(http.StatusOK, greeting)
}
func dbContextHandler(ctx *weavebox.Context) error {
	db := datastore{"mydatabase"}
	ctx.Context = newDatastoreContext(ctx.Context, &db)
	return nil
}