summaryrefslogtreecommitdiff
path: root/system/api/hide.go
diff options
context:
space:
mode:
Diffstat (limited to 'system/api/hide.go')
-rw-r--r--system/api/hide.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/system/api/hide.go b/system/api/hide.go
new file mode 100644
index 0000000..eed2c8b
--- /dev/null
+++ b/system/api/hide.go
@@ -0,0 +1,27 @@
+package api
+
+import (
+ "net/http"
+
+ "github.com/ponzu-cms/ponzu/system/item"
+)
+
+func hide(it interface{}, res http.ResponseWriter, req *http.Request) bool {
+ // check if should be hidden
+ if h, ok := it.(item.Hideable); ok {
+ err := h.Hide(res, req)
+ if err == item.ErrAllowHiddenItem {
+ return false
+ }
+
+ if err != nil {
+ res.WriteHeader(http.StatusInternalServerError)
+ return true
+ }
+
+ res.WriteHeader(http.StatusNotFound)
+ return true
+ }
+
+ return false
+}