encoding

package
v0.0.0-...-a0b01fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package encoding provide goa adapters to many different encoders.

Use the Consumes and Produces DSL in your design to specify the encoding supported by the service.

var _ = API("MyAPI", func() {
        // ...
        Consumes("application/json", "application/gob")
        Produces("application/json")
        // ...
})

The built-in encoder and decoder media types are:

  • application/json
  • application/xml
  • application/gob and application/x-gob
  • application/msgpack and application/x-msgpack
  • application/binc and application/x-binc
  • application/cbor and application/x-cbor

External encoders and decoders can also be specified via the DSL:

Produces("application/json", func() {   // Custom encoder
	Package("github.com/Gys/goa/encoding/json")
})

The DSL above causes the generated code to use the JSON encoder implemented in the package at github.com/Gys/goa/encoding/json rather than the stdlib JSON encoder. Third party encoders can easily be used via adapter packages that expose the NewDecoder and NewEcoder methods expected by the generated code, see the json package as an example.

Directories

Path Synopsis
Package form provides a "application/x-www-form-encoding" encoder and decoder.
Package form provides a "application/x-www-form-encoding" encoder and decoder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL