summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/build/Interfaces/Item/index.html20
-rw-r--r--docs/build/mkdocs/search_index.json12
-rw-r--r--docs/src/Interfaces/Item.md20
3 files changed, 26 insertions, 26 deletions
diff --git a/docs/build/Interfaces/Item/index.html b/docs/build/Interfaces/Item/index.html
index aafe017..dd6bd99 100644
--- a/docs/build/Interfaces/Item/index.html
+++ b/docs/build/Interfaces/Item/index.html
@@ -1528,16 +1528,16 @@ only method in Pushable, must return a <code>[]string</code> containing the <cod
of the referenced items within the type.</p>
<h5 id="method-set">Method Set<a class="headerlink" href="#method-set" title="Permanent link">&para;</a></h5>
<div class="codehilite"><pre><span></span><span class="kd">type</span> <span class="nx">Pushable</span> <span class="kd">interface</span> <span class="p">{</span>
- <span class="c1">// the values contained in fields returned by Push must be URL paths</span>
- <span class="nx">Push</span><span class="p">()</span> <span class="p">[]</span><span class="kt">string</span>
+ <span class="c1">// the values contained in []string fields returned by Push must be URL paths</span>
+ <span class="nx">Push</span><span class="p">(</span><span class="nx">http</span><span class="p">.</span><span class="nx">ResponseWriter</span><span class="p">,</span> <span class="o">*</span><span class="nx">http</span><span class="p">.</span><span class="nx">Request</span><span class="p">)</span> <span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="kt">error</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>
<h5 id="implementation">Implementation<a class="headerlink" href="#implementation" title="Permanent link">&para;</a></h5>
<p>The <code>Push</code> method returns a <code>[]string</code> containing the <code>json</code> tag field names for
-which you want to have pushed to a supported client. The values for the field
-names <strong>must</strong> be URL paths, and cannot be from another origin.</p>
+which you want to have pushed to a supported client and an error value. The values
+for the field names <strong>must</strong> be URL paths, and cannot be from another origin.</p>
<div class="codehilite"><pre><span></span><span class="kd">type</span> <span class="nx">Post</span> <span class="kd">struct</span> <span class="p">{</span>
<span class="nx">item</span><span class="p">.</span><span class="nx">Item</span>
@@ -1546,11 +1546,11 @@ names <strong>must</strong> be URL paths, and cannot be from another origin.</p>
<span class="c1">// ...</span>
<span class="p">}</span>
-<span class="kd">func</span> <span class="p">(</span><span class="nx">p</span> <span class="o">*</span><span class="nx">Post</span><span class="p">)</span> <span class="nx">Push</span><span class="p">()</span> <span class="p">[]</span><span class="kt">string</span> <span class="p">{</span>
+<span class="kd">func</span> <span class="p">(</span><span class="nx">p</span> <span class="o">*</span><span class="nx">Post</span><span class="p">)</span> <span class="nx">Push</span><span class="p">(</span><span class="nx">res</span> <span class="nx">http</span><span class="p">.</span><span class="nx">ResponseWriter</span><span class="p">,</span> <span class="nx">req</span> <span class="o">*</span><span class="nx">http</span><span class="p">.</span><span class="nx">Request</span><span class="p">)</span> <span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="kt">error</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">[]</span><span class="kt">string</span><span class="p">{</span>
<span class="s">&quot;header_photo&quot;</span><span class="p">,</span>
<span class="s">&quot;author&quot;</span><span class="p">,</span>
- <span class="p">}</span>
+ <span class="p">},</span> <span class="kc">nil</span>
<span class="p">}</span>
</pre></div>
@@ -1582,10 +1582,10 @@ content in specific cases.</p>
<p>Omittable tells a content API handler to keep certain fields from being exposed
through the JSON response. It's single method, <code>Omit</code> takes no arguments and
returns a <code>[]string</code> which must be made up of the JSON struct tags for the type
-containing fields to be omitted.</p>
+containing fields to be omitted and an error value.</p>
<h5 id="method-set_2">Method Set<a class="headerlink" href="#method-set_2" title="Permanent link">&para;</a></h5>
<div class="codehilite"><pre><span></span><span class="kd">type</span> <span class="nx">Omittable</span> <span class="kd">interface</span> <span class="p">{</span>
- <span class="nx">Omit</span><span class="p">()</span> <span class="p">[]</span><span class="kt">string</span>
+ <span class="nx">Omit</span><span class="p">(</span><span class="nx">http</span><span class="p">.</span><span class="nx">ResponseWriter</span><span class="p">,</span> <span class="o">*</span><span class="nx">http</span><span class="p">.</span><span class="nx">Request</span><span class="p">)</span> <span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="kt">error</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>
@@ -1599,11 +1599,11 @@ containing fields to be omitted.</p>
<span class="c1">// ...</span>
<span class="p">}</span>
-<span class="kd">func</span> <span class="p">(</span><span class="nx">p</span> <span class="o">*</span><span class="nx">Post</span><span class="p">)</span> <span class="nx">Omit</span><span class="p">()</span> <span class="p">[]</span><span class="kt">string</span> <span class="p">{</span>
+<span class="kd">func</span> <span class="p">(</span><span class="nx">p</span> <span class="o">*</span><span class="nx">Post</span><span class="p">)</span> <span class="nx">Omit</span><span class="p">(</span><span class="nx">res</span> <span class="nx">http</span><span class="p">.</span><span class="nx">ResponseWriter</span><span class="p">,</span> <span class="nx">req</span> <span class="o">*</span><span class="nx">http</span><span class="p">.</span><span class="nx">Request</span><span class="p">)</span> <span class="p">([]</span><span class="kt">string</span><span class="p">,</span> <span class="kt">error</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">[]</span><span class="kt">string</span><span class="p">{</span>
<span class="s">&quot;header_photo&quot;</span><span class="p">,</span>
<span class="s">&quot;author&quot;</span><span class="p">,</span>
- <span class="p">}</span>
+ <span class="p">},</span> <span class="kc">nil</span>
<span class="p">}</span>
</pre></div>
diff --git a/docs/build/mkdocs/search_index.json b/docs/build/mkdocs/search_index.json
index 5f4dc36..d9c1352 100644
--- a/docs/build/mkdocs/search_index.json
+++ b/docs/build/mkdocs/search_index.json
@@ -667,7 +667,7 @@
},
{
"location": "/Interfaces/Item/",
- "text": "Ponzu provides a set of interfaces from the \nsystem/item\n package which extend \nthe functionality of the content in your system and how it interacts with other \ncomponents inside and outside of Ponzu. \n\n\n\n\nInterfaces\n\n\nitem.Pushable\n\n\nPushable, if \nHTTP/2 Server Push\n \nis supported by the client, can tell a handler which resources it would like to \nhave \"pushed\" preemptively to the client. This saves follow-on roundtrip requests \nfor other items which are referenced by the Pushable item. The \nPush\n method, the \nonly method in Pushable, must return a \n[]string\n containing the \njson\n field tags \nof the referenced items within the type.\n\n\nMethod Set\n\n\ntype\n \nPushable\n \ninterface\n \n{\n\n \n// the values contained in fields returned by Push must be URL paths\n\n \nPush\n()\n \n[]\nstring\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nThe \nPush\n method returns a \n[]string\n containing the \njson\n tag field names for\nwhich you want to have pushed to a supported client. The values for the field\nnames \nmust\n be URL paths, and cannot be from another origin.\n\n\ntype\n \nPost\n \nstruct\n \n{\n\n \nitem\n.\nItem\n\n\n \nHeaderPhoto\n \nstring\n \n`json:\nheader_photo\n`\n\n \nAuthor\n \nstring\n \n`json:\nauthor\n`\n \n// reference `/api/content/?type=Author\nid=2`\n\n \n// ...\n\n\n}\n\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nPush\n()\n \n[]\nstring\n \n{\n\n \nreturn\n \n[]\nstring\n{\n\n \nheader_photo\n,\n\n \nauthor\n,\n\n \n}\n\n\n}\n\n\n\n\n\n\n\n\nitem.Hideable\n\n\nHideable tells an API handler that data of this type shouldn\u2019t be exposed outside \nthe system. Hideable types cannot be used as references (relations in Content types).\nThe \nHide\n method, the only method in Hideable, takes an \nhttp.ResponseWriter, *http.Request\n \nand returns an \nerror\n. A special error in the \nitems\n package, \nErrAllowHiddenItem\n \ncan be returned as the error from Hide to instruct handlers to show hidden \ncontent in specific cases.\n\n\nMethod Set\n\n\ntype\n \nHideable\n \ninterface\n \n{\n\n \nHide\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nHide\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\n\n\nitem.Omittable\n\n\nOmittable tells a content API handler to keep certain fields from being exposed \nthrough the JSON response. It's single method, \nOmit\n takes no arguments and \nreturns a \n[]string\n which must be made up of the JSON struct tags for the type \ncontaining fields to be omitted.\n\n\nMethod Set\n\n\ntype\n \nOmittable\n \ninterface\n \n{\n\n \nOmit\n()\n \n[]\nstring\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\ntype\n \nPost\n \nstruct\n \n{\n\n \nitem\n.\nItem\n\n\n \nHeaderPhoto\n \nstring\n \n`json:\nheader_photo\n`\n\n \nAuthor\n \nstring\n \n`json:\nauthor\n`\n\n \n// ...\n\n\n}\n\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nOmit\n()\n \n[]\nstring\n \n{\n\n \nreturn\n \n[]\nstring\n{\n\n \nheader_photo\n,\n\n \nauthor\n,\n\n \n}\n\n\n}\n\n\n\n\n\n\n\n\nitem.Hookable\n\n\nHookable provides lifecycle hooks into the http handlers which manage Save, Delete,\nApprove, and Reject routines. All methods in its set take an \n\nhttp.ResponseWriter, *http.Request\n and return an \nerror\n.\n\n\nMethod Set\n\n\ntype\n \nHookable\n \ninterface\n \n{\n\n \nBeforeAPICreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAPICreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAPIUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAPIUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAPIDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAPIDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAdminCreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAdminCreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAdminUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAdminUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAdminDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAdminDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeSave\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterSave\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeApprove\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterApprove\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeReject\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterReject\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \n// Enable/Disable used exclusively for addons\n\n \nBeforeEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n}\n\n\n\n\n\n\nImplementations\n\n\nBeforeAPICreate\n\n\nBeforeAPICreate is called before an item is created via a 3rd-party client. If a \nnon-nil \nerror\n value is returned, the item will not be created/saved.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAPICreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAPICreate\n\n\nAfterAPICreate is called after an item has been created via a 3rd-party client.\nAt this point, the item has been saved to the database. If a non-nil \nerror\n is\nreturned, it will respond to the client with an empty response, so be sure to \nuse the \nhttp.ResponseWriter\n from within your hook appropriately.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAPICreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeApprove\n\n\nBeforeApprove is called before an item is merged as \"Public\" from its prior \nstatus as \"Pending\". If a non-nil \nerror\n value is returned, the item will not be\nappproved, and an error message is displayed to the Admin. \n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeApprove\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterApprove\n\n\nAfterApprove is called after an item has been merged as \"Public\" from its prior\nstatus as \"Pending\". If a non-nil \nerror\n is returned, an error message is \ndisplayed to the Admin, however the item will already be irreversibly merged.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterApprove\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeReject\n\n\nBeforeReject is called before an item is rejected and deleted by default. To reject\nan item, but not delete it, return a non-nil \nerror\n from this hook - doing so \nwill allow the hook to do what you want it to do prior to the return, but the item\nwill remain in the \"Pending\" section.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeReject\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterReject\n\n\nAfterReject is called after an item is rejected and has been deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterReject\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeSave\n\n\nBeforeSave is called before any CMS Admin or 3rd-party client triggers a save to \nthe database. This could be done by clicking the 'Save' button on a Content editor, \nor by a API call to Create or Update the Content item. By returning a non-nil \n\nerror\n value, the item will not be saved.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeSave\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterSave\n\n\nAfterSave is called after any CMS Admin or 3rd-party client triggers a save to \nthe database. This could be done by clicking the 'Save' button on a Content editor, \nor by a API call to Create or Update the Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterSave\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeDelete\n\n\nBeforeDelete is called before any CMS Admin or 3rd-party client triggers a delete to \nthe database. This could be done by clicking the 'Delete' button on a Content editor, \nor by a API call to Delete the Content item. By returning a non-nil \nerror\n value,\nthe item will not be deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterDelete\n\n\nAfterSave is called after any CMS Admin or 3rd-party client triggers a delete to \nthe database. This could be done by clicking the 'Delete' button on a Content editor, \nor by a API call to Delete the Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAPIDelete\n\n\nBeforeDelete is only called before a 3rd-party client triggers a delete to the \ndatabase. By returning a non-nil \nerror\n value, the item will not be deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAPIDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAPIDelete\n\n\nAfterAPIDelete is only called after a 3rd-party client triggers a delete to the \ndatabase.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAPIDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAPIUpdate\n\n\nBeforeAPIUpdate is only called before a 3rd-party client triggers an update to \nthe database. By returning a non-nil \nerror\n value, the item will not be updated.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAPIUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAPIUpdate\n\n\nAfterAPIUpdate is only called after a 3rd-party client triggers an update to \nthe database.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAPIUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAdminCreate\n\n\nBeforeAdminCreate is only called before a CMS Admin creates a new Content item.\nIt is not called for subsequent saves to the item once it has been created and \nassigned an ID. By returning a non-nil \nerror\n value, the item will not be created.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAdminCreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAdminCreate\n\n\nAfterAdminCreate is only called after a CMS Admin creates a new Content item.\nIt is not called for subsequent saves to the item once it has been created and \nassigned an ID.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAdminCreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAdminUpdate\n\n\nBeforeAdminUpdate is only called before a CMS Admin updates a Content item. By \nreturning a non-nil \nerror\n, the item will not be updated.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAdminUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAdminUpdate\n\n\nAfterAdminUpdate is only called after a CMS Admin updates a Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAdminUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAdminDelete\n\n\nBeforeAdminDelete is only called before a CMS Admin deletes a Content item. By\nreturning a non-nil \nerror\n value, the item will not be deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAdminDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAdminDelete\n\n\nAfterAdminDelete is only called after a CMS Admin deletes a Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAdminDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeEnable\n\n\nBeforeEnable is only applicable to Addon items, and is called before the addon\nchanges status to \"Enabled\". By returning a non-nil \nerror\n value, the addon\nwill not become enabled.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterEnable\n\n\nAfterEnable is only applicable to Addon items, and is called after the addon \nchanges status to \"Enabled\".\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeDisable\n\n\nBeforeDisable is only applicable to Addon items, and is called before the addon\nchanges status to \"Disabled\". By returning a non-nil \nerror\n value, the addon\nwill not become disabled.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterDisable\n\n\nAfterDisable is only applicable to Addon items, and is called after the addon \nchanges status to \"Disabled\".\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nHookable is implemented by Item by default as no-ops which are expected to be overridden. \n\n\n\n\nNote\n\n\nreturning an error from any of these \nHookable\n methods will end the request, \ncausing it to halt immediately after the hook. For example, returning an \nerror\n \nfrom \nBeforeDelete\n will result in the content being kept in the database. \nThe same logic applies to all of these interface methods that return an error \n- \nthe error defines the behavior\n.\n\n\n\n\n\n\nitem.Identifiable\n\n\nIdentifiable enables a struct to have its ID set/get. Typically this is done to set an ID to -1 indicating it is new for DB inserts, since by default a newly initialized struct would have an ID of 0, the int zero-value, and BoltDB's starting key per bucket is 0, thus overwriting the first record.\nMost notable, Identifiable\u2019s \nString\n method is used to set a meaningful display name for an Item. \nString\n is called by default in the Admin dashboard to show the Items of certain types, and in the default creation of an Item\u2019s slug.\nIdentifiable is implemented by Item by default.\n\n\nMethod Set\n\n\ntype\n \nIdentifiable\n \ninterface\n \n{\n\n \nItemID\n()\n \nint\n\n \nSetItemID\n(\nint\n)\n\n \nUniqueID\n()\n \nuuid\n.\nUUID\n\n \nString\n()\n \nstring\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nitem.Identifiable\n has a default implementation in the \nsystem/item\n package. \nIt is not advised to override these methods, with the exception of \nString()\n, \nwhich is commonly used to set the display name of Content items when listed in \nthe CMS, and to customize slugs.\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nItemID\n()\n \nint\n \n{\n\n \nreturn\n \ni\n.\nID\n\n\n}\n\n\n\nfunc\n \n(\ni\n \n*\nItem\n)\n \nSetItemID\n(\nid\n \nint\n)\n \n{\n\n \ni\n.\nID\n \n=\n \nid\n\n\n}\n\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nUniqueID\n()\n \nuuid\n.\nUUID\n \n{\n\n \nreturn\n \ni\n.\nUUID\n\n\n}\n\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nString\n()\n \nstring\n \n{\n\n \nreturn\n \nfmt\n.\nSprintf\n(\nItem ID: %s\n,\n \ni\n.\nUniqueID\n())\n\n\n}\n\n\n\n\n\n\n\n\nitem.Sluggable\n\n\nSluggable makes a struct locatable by URL with it's own path. As an Item implementing Sluggable, slugs may overlap. If this is an issue, make your content struct (or one which embeds Item) implement Sluggable and it will override the slug created by Item's \nSetSlug\n method with your own.\nIt is not recommended to override \nSetSlug\n, but rather the \nString\n method on your content struct, which will have a similar, more predictable effect.\nSluggable is implemented by Item by default.\n\n\nMethod Set\n\n\ntype\n \nSluggable\n \ninterface\n \n{\n\n \nSetSlug\n(\nstring\n)\n\n \nItemSlug\n()\n \nstring\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nitem.Sluggable\n has a default implementation in the \nsystem/item\n package. It is\npossible to override these methods on your own Content types, but beware, behavior\nis undefined. It is tempting to override the \nSetSlug()\n method to customize your\nContent item slug, but try first to override the \nString()\n method found in the\n\nitem.Identifiable\n interface instead. If you don't get the desired results, try\n\nSetSlug()\n.\n\n\nfunc\n \n(\ni\n \n*\nItem\n)\n \nSetSlug\n(\nslug\n \nstring\n)\n \n{\n\n \ni\n.\nSlug\n \n=\n \nslug\n\n\n}\n\n\n\nfunc\n \n(\ni\n \n*\nItem\n)\n \nItemSlug\n()\n \nstring\n \n{\n\n \nreturn\n \ni\n.\nSlug\n\n\n}\n\n\n\n\n\n\n\n\nitem.Sortable\n\n\nSortable enables items to be sorted by time, as per the sort.Interface interface. Sortable is implemented by Item by default.\n\n\nMethod Set\n\n\ntype\n \nSortable\n \ninterface\n \n{\n\n \nTime\n()\n \nint64\n\n \nTouch\n()\n \nint64\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nitem.Sortable\n has a default implementation in the \nsystem/item\n package. It is\npossible to override these methods on your own Content type, but beware, behavior \nis undefined.\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nTime\n()\n \nint64\n \n{\n\n \nreturn\n \ni\n.\nTimestamp\n\n\n}\n\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nTouch\n()\n \nint64\n \n{\n\n \nreturn\n \ni\n.\nUpdated\n\n\n}",
+ "text": "Ponzu provides a set of interfaces from the \nsystem/item\n package which extend \nthe functionality of the content in your system and how it interacts with other \ncomponents inside and outside of Ponzu. \n\n\n\n\nInterfaces\n\n\nitem.Pushable\n\n\nPushable, if \nHTTP/2 Server Push\n \nis supported by the client, can tell a handler which resources it would like to \nhave \"pushed\" preemptively to the client. This saves follow-on roundtrip requests \nfor other items which are referenced by the Pushable item. The \nPush\n method, the \nonly method in Pushable, must return a \n[]string\n containing the \njson\n field tags \nof the referenced items within the type.\n\n\nMethod Set\n\n\ntype\n \nPushable\n \ninterface\n \n{\n\n \n// the values contained in []string fields returned by Push must be URL paths\n\n \nPush\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \n([]\nstring\n,\n \nerror\n)\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nThe \nPush\n method returns a \n[]string\n containing the \njson\n tag field names for\nwhich you want to have pushed to a supported client and an error value. The values \nfor the field names \nmust\n be URL paths, and cannot be from another origin.\n\n\ntype\n \nPost\n \nstruct\n \n{\n\n \nitem\n.\nItem\n\n\n \nHeaderPhoto\n \nstring\n \n`json:\nheader_photo\n`\n\n \nAuthor\n \nstring\n \n`json:\nauthor\n`\n \n// reference `/api/content/?type=Author\nid=2`\n\n \n// ...\n\n\n}\n\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nPush\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \n([]\nstring\n,\n \nerror\n)\n \n{\n\n \nreturn\n \n[]\nstring\n{\n\n \nheader_photo\n,\n\n \nauthor\n,\n\n \n},\n \nnil\n\n\n}\n\n\n\n\n\n\n\n\nitem.Hideable\n\n\nHideable tells an API handler that data of this type shouldn\u2019t be exposed outside \nthe system. Hideable types cannot be used as references (relations in Content types).\nThe \nHide\n method, the only method in Hideable, takes an \nhttp.ResponseWriter, *http.Request\n \nand returns an \nerror\n. A special error in the \nitems\n package, \nErrAllowHiddenItem\n \ncan be returned as the error from Hide to instruct handlers to show hidden \ncontent in specific cases.\n\n\nMethod Set\n\n\ntype\n \nHideable\n \ninterface\n \n{\n\n \nHide\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nHide\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\n\n\nitem.Omittable\n\n\nOmittable tells a content API handler to keep certain fields from being exposed \nthrough the JSON response. It's single method, \nOmit\n takes no arguments and \nreturns a \n[]string\n which must be made up of the JSON struct tags for the type \ncontaining fields to be omitted and an error value.\n\n\nMethod Set\n\n\ntype\n \nOmittable\n \ninterface\n \n{\n\n \nOmit\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \n([]\nstring\n,\n \nerror\n)\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\ntype\n \nPost\n \nstruct\n \n{\n\n \nitem\n.\nItem\n\n\n \nHeaderPhoto\n \nstring\n \n`json:\nheader_photo\n`\n\n \nAuthor\n \nstring\n \n`json:\nauthor\n`\n\n \n// ...\n\n\n}\n\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nOmit\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \n([]\nstring\n,\n \nerror\n)\n \n{\n\n \nreturn\n \n[]\nstring\n{\n\n \nheader_photo\n,\n\n \nauthor\n,\n\n \n},\n \nnil\n\n\n}\n\n\n\n\n\n\n\n\nitem.Hookable\n\n\nHookable provides lifecycle hooks into the http handlers which manage Save, Delete,\nApprove, and Reject routines. All methods in its set take an \n\nhttp.ResponseWriter, *http.Request\n and return an \nerror\n.\n\n\nMethod Set\n\n\ntype\n \nHookable\n \ninterface\n \n{\n\n \nBeforeAPICreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAPICreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAPIUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAPIUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAPIDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAPIDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAdminCreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAdminCreate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAdminUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAdminUpdate\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeAdminDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterAdminDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeSave\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterSave\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterDelete\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeApprove\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterApprove\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeReject\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterReject\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \n// Enable/Disable used exclusively for addons\n\n \nBeforeEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n \nBeforeDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n \nAfterDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n\n\n}\n\n\n\n\n\n\nImplementations\n\n\nBeforeAPICreate\n\n\nBeforeAPICreate is called before an item is created via a 3rd-party client. If a \nnon-nil \nerror\n value is returned, the item will not be created/saved.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAPICreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAPICreate\n\n\nAfterAPICreate is called after an item has been created via a 3rd-party client.\nAt this point, the item has been saved to the database. If a non-nil \nerror\n is\nreturned, it will respond to the client with an empty response, so be sure to \nuse the \nhttp.ResponseWriter\n from within your hook appropriately.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAPICreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeApprove\n\n\nBeforeApprove is called before an item is merged as \"Public\" from its prior \nstatus as \"Pending\". If a non-nil \nerror\n value is returned, the item will not be\nappproved, and an error message is displayed to the Admin. \n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeApprove\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterApprove\n\n\nAfterApprove is called after an item has been merged as \"Public\" from its prior\nstatus as \"Pending\". If a non-nil \nerror\n is returned, an error message is \ndisplayed to the Admin, however the item will already be irreversibly merged.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterApprove\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeReject\n\n\nBeforeReject is called before an item is rejected and deleted by default. To reject\nan item, but not delete it, return a non-nil \nerror\n from this hook - doing so \nwill allow the hook to do what you want it to do prior to the return, but the item\nwill remain in the \"Pending\" section.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeReject\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterReject\n\n\nAfterReject is called after an item is rejected and has been deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterReject\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeSave\n\n\nBeforeSave is called before any CMS Admin or 3rd-party client triggers a save to \nthe database. This could be done by clicking the 'Save' button on a Content editor, \nor by a API call to Create or Update the Content item. By returning a non-nil \n\nerror\n value, the item will not be saved.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeSave\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterSave\n\n\nAfterSave is called after any CMS Admin or 3rd-party client triggers a save to \nthe database. This could be done by clicking the 'Save' button on a Content editor, \nor by a API call to Create or Update the Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterSave\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeDelete\n\n\nBeforeDelete is called before any CMS Admin or 3rd-party client triggers a delete to \nthe database. This could be done by clicking the 'Delete' button on a Content editor, \nor by a API call to Delete the Content item. By returning a non-nil \nerror\n value,\nthe item will not be deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterDelete\n\n\nAfterSave is called after any CMS Admin or 3rd-party client triggers a delete to \nthe database. This could be done by clicking the 'Delete' button on a Content editor, \nor by a API call to Delete the Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAPIDelete\n\n\nBeforeDelete is only called before a 3rd-party client triggers a delete to the \ndatabase. By returning a non-nil \nerror\n value, the item will not be deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAPIDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAPIDelete\n\n\nAfterAPIDelete is only called after a 3rd-party client triggers a delete to the \ndatabase.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAPIDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAPIUpdate\n\n\nBeforeAPIUpdate is only called before a 3rd-party client triggers an update to \nthe database. By returning a non-nil \nerror\n value, the item will not be updated.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAPIUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAPIUpdate\n\n\nAfterAPIUpdate is only called after a 3rd-party client triggers an update to \nthe database.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAPIUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAdminCreate\n\n\nBeforeAdminCreate is only called before a CMS Admin creates a new Content item.\nIt is not called for subsequent saves to the item once it has been created and \nassigned an ID. By returning a non-nil \nerror\n value, the item will not be created.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAdminCreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAdminCreate\n\n\nAfterAdminCreate is only called after a CMS Admin creates a new Content item.\nIt is not called for subsequent saves to the item once it has been created and \nassigned an ID.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAdminCreate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAdminUpdate\n\n\nBeforeAdminUpdate is only called before a CMS Admin updates a Content item. By \nreturning a non-nil \nerror\n, the item will not be updated.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAdminUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAdminUpdate\n\n\nAfterAdminUpdate is only called after a CMS Admin updates a Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAdminUpdate\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeAdminDelete\n\n\nBeforeAdminDelete is only called before a CMS Admin deletes a Content item. By\nreturning a non-nil \nerror\n value, the item will not be deleted.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeAdminDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterAdminDelete\n\n\nAfterAdminDelete is only called after a CMS Admin deletes a Content item.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterAdminDelete\n(\nres\n \nhttp\n.\nResponseWriter\n,\n \nreq\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeEnable\n\n\nBeforeEnable is only applicable to Addon items, and is called before the addon\nchanges status to \"Enabled\". By returning a non-nil \nerror\n value, the addon\nwill not become enabled.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterEnable\n\n\nAfterEnable is only applicable to Addon items, and is called after the addon \nchanges status to \"Enabled\".\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterEnable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nBeforeDisable\n\n\nBeforeDisable is only applicable to Addon items, and is called before the addon\nchanges status to \"Disabled\". By returning a non-nil \nerror\n value, the addon\nwill not become disabled.\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nBeforeDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nAfterDisable\n\n\nAfterDisable is only applicable to Addon items, and is called after the addon \nchanges status to \"Disabled\".\n\n\nfunc\n \n(\np\n \n*\nPost\n)\n \nAfterDisable\n(\nhttp\n.\nResponseWriter\n,\n \n*\nhttp\n.\nRequest\n)\n \nerror\n \n{\n\n \nreturn\n \nnil\n\n\n}\n\n\n\n\n\n\nHookable is implemented by Item by default as no-ops which are expected to be overridden. \n\n\n\n\nNote\n\n\nreturning an error from any of these \nHookable\n methods will end the request, \ncausing it to halt immediately after the hook. For example, returning an \nerror\n \nfrom \nBeforeDelete\n will result in the content being kept in the database. \nThe same logic applies to all of these interface methods that return an error \n- \nthe error defines the behavior\n.\n\n\n\n\n\n\nitem.Identifiable\n\n\nIdentifiable enables a struct to have its ID set/get. Typically this is done to set an ID to -1 indicating it is new for DB inserts, since by default a newly initialized struct would have an ID of 0, the int zero-value, and BoltDB's starting key per bucket is 0, thus overwriting the first record.\nMost notable, Identifiable\u2019s \nString\n method is used to set a meaningful display name for an Item. \nString\n is called by default in the Admin dashboard to show the Items of certain types, and in the default creation of an Item\u2019s slug.\nIdentifiable is implemented by Item by default.\n\n\nMethod Set\n\n\ntype\n \nIdentifiable\n \ninterface\n \n{\n\n \nItemID\n()\n \nint\n\n \nSetItemID\n(\nint\n)\n\n \nUniqueID\n()\n \nuuid\n.\nUUID\n\n \nString\n()\n \nstring\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nitem.Identifiable\n has a default implementation in the \nsystem/item\n package. \nIt is not advised to override these methods, with the exception of \nString()\n, \nwhich is commonly used to set the display name of Content items when listed in \nthe CMS, and to customize slugs.\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nItemID\n()\n \nint\n \n{\n\n \nreturn\n \ni\n.\nID\n\n\n}\n\n\n\nfunc\n \n(\ni\n \n*\nItem\n)\n \nSetItemID\n(\nid\n \nint\n)\n \n{\n\n \ni\n.\nID\n \n=\n \nid\n\n\n}\n\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nUniqueID\n()\n \nuuid\n.\nUUID\n \n{\n\n \nreturn\n \ni\n.\nUUID\n\n\n}\n\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nString\n()\n \nstring\n \n{\n\n \nreturn\n \nfmt\n.\nSprintf\n(\nItem ID: %s\n,\n \ni\n.\nUniqueID\n())\n\n\n}\n\n\n\n\n\n\n\n\nitem.Sluggable\n\n\nSluggable makes a struct locatable by URL with it's own path. As an Item implementing Sluggable, slugs may overlap. If this is an issue, make your content struct (or one which embeds Item) implement Sluggable and it will override the slug created by Item's \nSetSlug\n method with your own.\nIt is not recommended to override \nSetSlug\n, but rather the \nString\n method on your content struct, which will have a similar, more predictable effect.\nSluggable is implemented by Item by default.\n\n\nMethod Set\n\n\ntype\n \nSluggable\n \ninterface\n \n{\n\n \nSetSlug\n(\nstring\n)\n\n \nItemSlug\n()\n \nstring\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nitem.Sluggable\n has a default implementation in the \nsystem/item\n package. It is\npossible to override these methods on your own Content types, but beware, behavior\nis undefined. It is tempting to override the \nSetSlug()\n method to customize your\nContent item slug, but try first to override the \nString()\n method found in the\n\nitem.Identifiable\n interface instead. If you don't get the desired results, try\n\nSetSlug()\n.\n\n\nfunc\n \n(\ni\n \n*\nItem\n)\n \nSetSlug\n(\nslug\n \nstring\n)\n \n{\n\n \ni\n.\nSlug\n \n=\n \nslug\n\n\n}\n\n\n\nfunc\n \n(\ni\n \n*\nItem\n)\n \nItemSlug\n()\n \nstring\n \n{\n\n \nreturn\n \ni\n.\nSlug\n\n\n}\n\n\n\n\n\n\n\n\nitem.Sortable\n\n\nSortable enables items to be sorted by time, as per the sort.Interface interface. Sortable is implemented by Item by default.\n\n\nMethod Set\n\n\ntype\n \nSortable\n \ninterface\n \n{\n\n \nTime\n()\n \nint64\n\n \nTouch\n()\n \nint64\n\n\n}\n\n\n\n\n\n\nImplementation\n\n\nitem.Sortable\n has a default implementation in the \nsystem/item\n package. It is\npossible to override these methods on your own Content type, but beware, behavior \nis undefined.\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nTime\n()\n \nint64\n \n{\n\n \nreturn\n \ni\n.\nTimestamp\n\n\n}\n\n\n\nfunc\n \n(\ni\n \nItem\n)\n \nTouch\n()\n \nint64\n \n{\n\n \nreturn\n \ni\n.\nUpdated\n\n\n}",
"title": "Item"
},
{
@@ -682,12 +682,12 @@
},
{
"location": "/Interfaces/Item/#method-set",
- "text": "type Pushable interface { \n // the values contained in fields returned by Push must be URL paths \n Push () [] string }",
+ "text": "type Pushable interface { \n // the values contained in []string fields returned by Push must be URL paths \n Push ( http . ResponseWriter , * http . Request ) ([] string , error ) }",
"title": "Method Set"
},
{
"location": "/Interfaces/Item/#implementation",
- "text": "The Push method returns a []string containing the json tag field names for\nwhich you want to have pushed to a supported client. The values for the field\nnames must be URL paths, and cannot be from another origin. type Post struct { \n item . Item \n\n HeaderPhoto string `json: header_photo ` \n Author string `json: author ` // reference `/api/content/?type=Author id=2` \n // ... } func ( p * Post ) Push () [] string { \n return [] string { \n header_photo , \n author , \n } }",
+ "text": "The Push method returns a []string containing the json tag field names for\nwhich you want to have pushed to a supported client and an error value. The values \nfor the field names must be URL paths, and cannot be from another origin. type Post struct { \n item . Item \n\n HeaderPhoto string `json: header_photo ` \n Author string `json: author ` // reference `/api/content/?type=Author id=2` \n // ... } func ( p * Post ) Push ( res http . ResponseWriter , req * http . Request ) ([] string , error ) { \n return [] string { \n header_photo , \n author , \n }, nil }",
"title": "Implementation"
},
{
@@ -707,17 +707,17 @@
},
{
"location": "/Interfaces/Item/#itemomittable",
- "text": "Omittable tells a content API handler to keep certain fields from being exposed \nthrough the JSON response. It's single method, Omit takes no arguments and \nreturns a []string which must be made up of the JSON struct tags for the type \ncontaining fields to be omitted.",
+ "text": "Omittable tells a content API handler to keep certain fields from being exposed \nthrough the JSON response. It's single method, Omit takes no arguments and \nreturns a []string which must be made up of the JSON struct tags for the type \ncontaining fields to be omitted and an error value.",
"title": "item.Omittable"
},
{
"location": "/Interfaces/Item/#method-set_2",
- "text": "type Omittable interface { \n Omit () [] string }",
+ "text": "type Omittable interface { \n Omit ( http . ResponseWriter , * http . Request ) ([] string , error ) }",
"title": "Method Set"
},
{
"location": "/Interfaces/Item/#implementation_2",
- "text": "type Post struct { \n item . Item \n\n HeaderPhoto string `json: header_photo ` \n Author string `json: author ` \n // ... } func ( p * Post ) Omit () [] string { \n return [] string { \n header_photo , \n author , \n } }",
+ "text": "type Post struct { \n item . Item \n\n HeaderPhoto string `json: header_photo ` \n Author string `json: author ` \n // ... } func ( p * Post ) Omit ( res http . ResponseWriter , req * http . Request ) ([] string , error ) { \n return [] string { \n header_photo , \n author , \n }, nil }",
"title": "Implementation"
},
{
diff --git a/docs/src/Interfaces/Item.md b/docs/src/Interfaces/Item.md
index 32f250b..00971aa 100644
--- a/docs/src/Interfaces/Item.md
+++ b/docs/src/Interfaces/Item.md
@@ -19,15 +19,15 @@ of the referenced items within the type.
##### Method Set
```go
type Pushable interface {
- // the values contained in fields returned by Push must be URL paths
- Push() []string
+ // the values contained in []string fields returned by Push must be URL paths
+ Push(http.ResponseWriter, *http.Request) ([]string, error)
}
```
##### Implementation
The `Push` method returns a `[]string` containing the `json` tag field names for
-which you want to have pushed to a supported client. The values for the field
-names **must** be URL paths, and cannot be from another origin.
+which you want to have pushed to a supported client and an error value. The values
+for the field names **must** be URL paths, and cannot be from another origin.
```go
type Post struct {
@@ -38,11 +38,11 @@ type Post struct {
// ...
}
-func (p *Post) Push() []string {
+func (p *Post) Push(res http.ResponseWriter, req *http.Request) ([]string, error) {
return []string{
"header_photo",
"author",
- }
+ }, nil
}
```
@@ -76,12 +76,12 @@ func (p *Post) Hide(res http.ResponseWriter, req *http.Request) error {
Omittable tells a content API handler to keep certain fields from being exposed
through the JSON response. It's single method, `Omit` takes no arguments and
returns a `[]string` which must be made up of the JSON struct tags for the type
-containing fields to be omitted.
+containing fields to be omitted and an error value.
##### Method Set
```go
type Omittable interface {
- Omit() []string
+ Omit(http.ResponseWriter, *http.Request) ([]string, error)
}
```
@@ -95,11 +95,11 @@ type Post struct {
// ...
}
-func (p *Post) Omit() []string {
+func (p *Post) Omit(res http.ResponseWriter, req *http.Request) ([]string, error) {
return []string{
"header_photo",
"author",
- }
+ }, nil
}
```