// RequestForm makes an HTTP request with the given interface being encoded as // form data. func (c *Client) RequestForm(verb, p string, i interface{}, ro *RequestOptions) (*http.Response, error) { if ro == nil { ro = new(RequestOptions) } if ro.Headers == nil { ro.Headers = make(map[string]string) } ro.Headers["Content-Type"] = "application/x-www-form-urlencoded" buf := new(bytes.Buffer) if err := form.NewEncoder(buf).DelimitWith('|').Encode(i); err != nil { return nil, err } body := buf.String() ro.Body = strings.NewReader(body) ro.BodyLength = int64(len(body)) return c.Request(verb, p, ro) }
// NewEncoder returns a form encoder that writes to w. func NewEncoder(w io.Writer) goa.Encoder { return form.NewEncoder(w) }