github.com/shogo-ma/goa@v1.3.1/encoding/doc.go (about) 1 /* 2 Package encoding provide goa adapters to many different encoders. 3 4 Use the Consumes and Produces DSL in your design to specify the encoding supported by the service. 5 6 var _ = API("MyAPI", func() { 7 // ... 8 Consumes("application/json", "application/gob") 9 Produces("application/json") 10 // ... 11 }) 12 13 The built-in encoder and decoder media types are: 14 15 - application/json 16 - application/xml 17 - application/gob and application/x-gob 18 - application/msgpack and application/x-msgpack 19 - application/binc and application/x-binc 20 - application/cbor and application/x-cbor 21 22 External encoders and decoders can also be specified via the DSL: 23 24 Produces("application/json", func() { // Custom encoder 25 Package("github.com/goadesign/goa/encoding/json") 26 }) 27 28 The DSL above causes the generated code to use the JSON encoder implemented in the package at 29 github.com/goadesign/goa/encoding/json rather than the stdlib JSON encoder. Third party encoders 30 can easily be used via adapter packages that expose the NewDecoder and NewEcoder methods expected 31 by the generated code, see the json package as an example. 32 */ 33 package encoding