github.com/rpdict/ponzu@v0.10.1-0.20190226054626-477f29d6bf5e/examples/createable/README.md (about) 1 # Createable 2 3 This example shows how to enable outside clients to submit content to your CMS. 4 All content submitted must be done through a POST request encoded as `multipart/form-data` 5 to the API endpoint `/api/content/create?type=<Type>` 6 7 ## Song example 8 Imagine an app that lets users add Spotify music to a global playlist, and you need them 9 to supply songs in the format: 10 ```go 11 type Song struct { 12 item.Item 13 14 Title string `json:"title"` 15 Artist string `json:"artist"` 16 Rating int `json:"rating"` 17 Opinion string `json:"opinion"` 18 SpotifyURL string `json:"spotify_url"` 19 } 20 ``` 21 22 See the file `content/song.go` and read the comments to understand the various 23 methods needed to satisfy required interfaces for this kind of activity. 24 25 ### Overview 26 1. Implement `api.Createable` with the `Create(http.ResponseWriter, *http.Request) error` method to allow outside POST requests 27 2. Implement `editor.Mergeable` with the `Approve(http.ResponseWriter, *http.Request) error` method so you can control the Approval / Rejection of submitted content OR 28 3. Implement `api.Trustable` with the `AutoApprove(http.ResponseWriter, *http.Request) error` method to bypass `Approve` and auto-approve and publish submitted content 29 30 There are various validation and request checks shown in this example as well. 31 Please feel free to modify and submit a PR for updates or bug fixes!