Esempio n. 1
0
// Controller for adding existing element to wrapper element or path.
func AddExistingChild(w *wrapper.Wrapper) {
	var parenttype string
	if len(w.APIParams) > 1 {
		parenttype = w.APIParams[0]
	} else {
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
		return
	}
	if w.Request.Method != "POST" {
		AddExistingChildForm(w)
		return
	}
	w.Shift()
	switch parenttype {
	case "wrapper":
		AddExistingWrapperSubmit(w)
		return
	case "paths":
		AddExistingPathSubmit(w)
		return
	default:
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
	}
	return
}
Esempio n. 2
0
func (l *LoginMap) Login(w *wrapper.Wrapper) {
	if controller, ok := l.Controllers[w.APIParams[0]]; ok {
		w.Shift()
		controller(w)
		return
	}
	http.Error(w.Writer, "Forbidden", 403)
	return
}
Esempio n. 3
0
//Main controller for all admin functions
func (a AdminMap) Admin(w *wrapper.Wrapper) {
	if c, ok := a[w.APIParams[0]]; ok {
		if validateAdmin(w) {
			w.Shift()
			c(w)
		}
		return
	} else {
		http.Error(w.Writer, "Forbidden", 403)
		return
	}
}
Esempio n. 4
0
//Main controller for all admin functions
func (a AdminMap) Admin(w *wrapper.Wrapper) {
	w.Writer.Header().Add("Cache-Control", "no-cache, no-store, must-revalidate")
	w.Writer.Header().Add("Pragma", "no-cache")
	w.Writer.Header().Add("Expires", "0")
	if c, ok := a[w.APIParams[0]]; ok {
		if validateAdmin(w) {
			w.Shift()
			c(w)
		}
		return
	} else {
		http.Error(w.Writer, "Forbidden", 403)
		return
	}
}
Esempio n. 5
0
// Controller for adding children to wrapper element or path.
func AddChild(w *wrapper.Wrapper) {
	var parenttype string
	if len(w.APIParams) > 1 {
		parenttype = w.APIParams[0]
	} else {
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
		return
	}
	w.Shift()
	switch parenttype {
	case "wrapper":
		AddWrapperChild(w)
	case "slug":
		AddSlugChild(w)
	case "paths":
		AddPathChild(w)
	default:
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
	}
	return
}
Esempio n. 6
0
// This controller deletes paths and elements
func Delete(w *wrapper.Wrapper) {
	var parenttype string
	if len(w.APIParams) > 1 {
		parenttype = w.APIParams[0]
	} else {
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
		return
	}
	w.Shift()
	switch parenttype {
	case "elements":
		DeleteElement(w)
		return
	case "paths":
		DeletePath(w)
		return
	default:
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
	}
	return
}