code: func (encoder *HTTPEncoder) Encode(v interface{}, resp io.Writer, accept string) error {
  	now := time.Now()
  	if accept == "" {
  		accept = "*/*"
  	}
  	var contentType string
  	for _, t := range encoder.contentTypes {
  		if accept == "*/*" || accept == t {
  			contentType = accept
  			break
  		}
  	}
  	defer MeasureSince([]string{"goa", "encode", contentType}, now)
  	p := encoder.pools[contentType]
  	if p == nil && contentType != "*/*" {
  		p = encoder.pools["*/*"]
  	}
  	if p == nil {
  		return fmt.Errorf("No encoder registered for %s and no default encoder", contentType)
  	}
  
  	// the encoderPool will handle whether or not a pool is actually in use
  	e := p.Get(resp)
  	if err := e.Encode(v); err != nil {
  		return err
  	}
  	p.Put(e)
  
  	return nil
  }
docs: // Encode uses the registered encoders and given content type to marshal and write the given value
  // using the given writer.