Beispiel #1
0
// 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")
}
Beispiel #2
0
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)
}