diff options
author | Steve <nilslice@gmail.com> | 2017-03-11 13:15:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-11 13:15:16 -0800 |
commit | 88d0ebf9d6dd764c82a4a8ac702064e7f504bc25 (patch) | |
tree | 1dbf6c9a405c81db780dba16727dea0465070732 /examples/updateable/README.md | |
parent | a69060728b5f99bb41c9562dcd294f6fc74d4b22 (diff) | |
parent | 7ea4aac0ec47e3f04e8d5ffc40433885fe11e207 (diff) |
Merge pull request #97 from kkeuning/updateable-example
Updateable example added
Diffstat (limited to 'examples/updateable/README.md')
-rw-r--r-- | examples/updateable/README.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/updateable/README.md b/examples/updateable/README.md new file mode 100644 index 0000000..1cc50f8 --- /dev/null +++ b/examples/updateable/README.md @@ -0,0 +1,31 @@ +# Updateable + +This example shows how to enable outside clients to update content to your CMS. +All content submitted must be done through a POST request encoded as `multipart/form-data` +to the API endpoint `/api/content/update?type=<Type>&id=<id>` + +## Song example +Imagine an app that lets users add Spotify music to a global playlist, and you need them +to supply songs in the format: +```go +type Song struct { + item.Item + + Title string `json:"title"` + Artist string `json:"artist"` + Rating int `json:"rating"` + Opinion string `json:"opinion"` + SpotifyURL string `json:"spotify_url"` +} +``` + +See the file `content/song.go` and read the comments to understand the various +methods needed to satisfy required interfaces for this kind of activity. + +### Overview +1. Implement `api.Updateable` with the `AcceptUpdate(http.ResponseWriter, *http.Request)` method to allow outside POST requests. +2. Consistent with the externalable example, authentication can be validated in `BeforeAcceptUdate(http.ResponseWriter, *http.Request)` + +There are various validation and request checks shown in this example as well. +Please feel free to modify and submit a PR for updates or bug fixes! + |