func WithFormData(v url.Values) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r, err := p.Prepare(r)
			if err == nil {
				s := v.Encode()
				r.ContentLength = int64(len(s))
				r.Body = ioutil.NopCloser(strings.NewReader(s))
			}
			return r, err
		})
	}
}
WithFormData returns a PrepareDecoratore that "URL encodes" (e.g., bar=baz&foo=quux) into the
http.Request body.
package autorest
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
)
const (
	mimeTypeJSON     = "application/json"
	mimeTypeFormPost = "application/x-www-form-urlencoded"
	headerAuthorization = "Authorization"
	headerContentType   = "Content-Type"
	headerUserAgent     = "User-Agent"
)
type Preparer interface {
	Prepare(*http.Request) (*http.Request, error)
}
type PreparerFunc func(*http.Request) (*http.Request, error)
func (pf PreparerFunc) Prepare(r *http.Request) (*http.Request, error) {
	return pf(r)
}
type PrepareDecorator func(Preparer) Preparer
func CreatePreparer(decorators ...PrepareDecorator) Preparer {
	return DecoratePreparer(
		Preparer(PreparerFunc(func(r *http.Request) (*http.Request, error) { return r, nil })),
		decorators...)
}
func DecoratePreparer(p Preparer, decorators ...PrepareDecorator) Preparer {
	for _, decorate := range decorators {
		p = decorate(p)
	}
	return p
}
func Prepare(r *http.Request, decorators ...PrepareDecorator) (*http.Request, error) {
	if r == nil {
		return nil, NewError("autorest", "Prepare", "Invoked without an http.Request")
	}
	return CreatePreparer(decorators...).Prepare(r)
}
func WithNothing() PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			return p.Prepare(r)
		})
	}
}
func WithHeader(header string, value string) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r, err := p.Prepare(r)
			if err == nil {
				if r.Header == nil {
					r.Header = make(http.Header)
				}
				r.Header.Set(http.CanonicalHeaderKey(header), value)
			}
			return r, err
		})
	}
}
func WithBearerAuthorization(token string) PrepareDecorator {
	return WithHeader(headerAuthorization, fmt.Sprintf("Bearer %s", token))
}
func AsContentType(contentType string) PrepareDecorator {
	return WithHeader(headerContentType, contentType)
}
func WithUserAgent(ua string) PrepareDecorator {
	return WithHeader(headerUserAgent, ua)
}
func AsFormURLEncoded() PrepareDecorator {
	return AsContentType(mimeTypeFormPost)
}
func AsJSON() PrepareDecorator {
	return AsContentType(mimeTypeJSON)
}
func WithMethod(method string) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r.Method = method
			return p.Prepare(r)
		})
	}
}
func AsDelete() PrepareDecorator { return WithMethod("DELETE") }
func AsGet() PrepareDecorator { return WithMethod("GET") }
func AsHead() PrepareDecorator { return WithMethod("HEAD") }
func AsOptions() PrepareDecorator { return WithMethod("OPTIONS") }
func AsPatch() PrepareDecorator { return WithMethod("PATCH") }
func AsPost() PrepareDecorator { return WithMethod("POST") }
func AsPut() PrepareDecorator { return WithMethod("PUT") }
func WithBaseURL(baseURL string) PrepareDecorator {
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r, err := p.Prepare(r)
			if err == nil {
				var u *url.URL
				u, err = url.Parse(baseURL)
				if u.Scheme == "" {
					err = fmt.Errorf("autorest: No scheme detected in URL %s", baseURL)
				}
				if err == nil {
					r.URL = u
				}
			}
			return r, err
		})
	}
}