コミット
4870298a37
|
@ -18,7 +18,7 @@ into its proper type, passed to the corresponding callback.
|
||||||
|
|
||||||
For example, given the data:
|
For example, given the data:
|
||||||
|
|
||||||
```
|
```golang
|
||||||
{
|
{
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"type": "Note",
|
"type": "Note",
|
||||||
|
@ -30,7 +30,7 @@ For example, given the data:
|
||||||
|
|
||||||
in `b []byte` one can do the following:
|
in `b []byte` one can do the following:
|
||||||
|
|
||||||
```
|
```golang
|
||||||
var m map[string]interface{}
|
var m map[string]interface{}
|
||||||
if err := json.Unmarshal(b, &m); err != nil {
|
if err := json.Unmarshal(b, &m); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -64,7 +64,7 @@ For every type in this package (except `Resolver`), there is an equivalent type
|
||||||
in the `activity/vocab` package. It takes only a call to `Raw` to go from this
|
in the `activity/vocab` package. It takes only a call to `Raw` to go from this
|
||||||
convenience API to the full API:
|
convenience API to the full API:
|
||||||
|
|
||||||
```
|
```golang
|
||||||
r := &Resolver {
|
r := &Resolver {
|
||||||
NoteCallback: func(n *Note) error {
|
NoteCallback: func(n *Note) error {
|
||||||
// Raw is available for all ActivityStream types
|
// Raw is available for all ActivityStream types
|
||||||
|
@ -82,7 +82,7 @@ client code that tries to handle every possible type that `attachment` can
|
||||||
take. **The W3C does not require client applications to support all of these
|
take. **The W3C does not require client applications to support all of these
|
||||||
use cases.**
|
use cases.**
|
||||||
|
|
||||||
```
|
```golang
|
||||||
r := &Resolver {}
|
r := &Resolver {}
|
||||||
r.NoteCallback = func(n *Note) error {
|
r.NoteCallback = func(n *Note) error {
|
||||||
if n.LenAttachment() == 1 {
|
if n.LenAttachment() == 1 {
|
||||||
|
@ -112,7 +112,7 @@ r.NoteCallback = func(n *Note) error {
|
||||||
|
|
||||||
Creating a raw type and serializing it is straightforward:
|
Creating a raw type and serializing it is straightforward:
|
||||||
|
|
||||||
```
|
```golang
|
||||||
n := &Note{}
|
n := &Note{}
|
||||||
n.AddName("I'll see you again")
|
n.AddName("I'll see you again")
|
||||||
n.AddContent("You don't have to be alone when I leave")
|
n.AddContent("You don't have to be alone when I leave")
|
||||||
|
|
読み込み中…
新しいイシューから参照