forked from Mirrors/jsonapi
work on README
This commit is contained in:
parent
c82586a2bb
commit
1514449cab
31
README.md
31
README.md
|
@ -95,11 +95,37 @@ type Comment struct {
|
||||||
|
|
||||||
## Handler Examples
|
## Handler Examples
|
||||||
|
|
||||||
Now you have your structs prepared to be seralized or materialized.
|
Now you have your structs are prepared to be seralized or materialized.
|
||||||
What about the rest?
|
What about the rest?
|
||||||
|
|
||||||
### Create
|
### Create
|
||||||
|
|
||||||
|
You can Unmarshal a jsonapi payload using `jsonapi.UnmarshalPayload`; convert an io
|
||||||
|
into a struct instance using jsonapi tags on struct fields. Method supports single
|
||||||
|
request payloads only, at the moment. Bulk creates and updates are not supported yet.
|
||||||
|
|
||||||
|
#### `UnmarshalPayload`
|
||||||
|
|
||||||
|
```go
|
||||||
|
UnmarshalPayload(in io.Reader, model interface{})
|
||||||
|
```
|
||||||
|
|
||||||
|
Visit [godoc](http://godoc.org/github.com/shwoodard/jsonapi#UnmarshalPayload)
|
||||||
|
|
||||||
|
#### `MarshalOnePayload`
|
||||||
|
|
||||||
|
This method encodes a response for a single record only. If you want to serialize many
|
||||||
|
records, see, [MarshalManyPayload](#MarshalManyPayload). Wrties a jsonapi response, with
|
||||||
|
related records sideloaded, into `included` array.
|
||||||
|
|
||||||
|
```go
|
||||||
|
MarshalOnePayloadEmbedded(w io.Writer, model interface{}) error
|
||||||
|
```
|
||||||
|
|
||||||
|
Visit [godoc](http://godoc.org/github.com/shwoodard/jsonapi#MarshalOnePayload)
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func CreateBlog(w http.ResponseWriter, r *http.Request) {
|
func CreateBlog(w http.ResponseWriter, r *http.Request) {
|
||||||
blog := new(Blog)
|
blog := new(Blog)
|
||||||
|
@ -120,3 +146,6 @@ func CreateBlog(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### List
|
||||||
|
#### `MarshalManyPayload`
|
||||||
|
#### Example
|
||||||
|
|
Loading…
Reference in New Issue