func (c *peopleCollection) Post(vars RouteVars, r *http.Request) (Resource, string, error) {
	if r.Header.Get("Content-Type") != "application/json" {
		return nil, "", UnsupportedMediaType("application/json")
	}
	return testPeople[0], "https://", nil
}
Post returns the first item in testPeople as if it was just created.
package rst
import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"strings"
	"testing"
	"time"
)
var (
	testHost                     = "127.0.0.1:55839"
	testServerAddr               = "http://" + testHost
	testMux                      *Mux
	testMBText                   []byte
	testSafeURL                  string
	testEchoURL                  string
	testEnvelopeURL              string
	testBypassURL                string
	testPeople                   []*person
	testPeopleResourceCollection resourceCollection
)
const (
	testContentType   = "hello/world"
	testCannedContent = "hello, world!"
)
var (
	testCannedBytes   = []byte(testCannedContent)
	testTimeReference = time.Date(2014, 4, 14, 10, 0, 0, 0, time.UTC)
)
type employer struct {
	Company   string `json:"company"`
	Continent string `json:"continent"`
}
func (e *employer) LastModified() time.Time {
	return testTimeReference
}
func (e *employer) ETag() string {
	return fmt.Sprintf("%s-%d", e.Company, e.LastModified().Unix())
}
func (e *employer) TTL() time.Duration {
	return 15 * time.Minute
}
func (e *employer) MarshalRST(r *http.Request) (string, []byte, error) {
	accept := ParseAccept(r.Header.Get("Accept"))
	if accept.Negotiate(testContentType) == testContentType {
		return testContentType, testCannedBytes, nil
	}
	return MarshalResource(e, r)
}
type person struct {
	ID        string    `json:"_id"`
	Age       int       `json:"age"`
	EyeColor  string    `json:"eyeColor"`
	Firstname string    `json:"firstname"`
	Lastname  string    `json:"lastname"`
	Employer  *employer `json:"employer"`
}
func (p *person) LastModified() time.Time {
	return testTimeReference
}
func (p *person) ETag() string {
	return fmt.Sprintf("%s-%d", p.ID, p.LastModified().Unix())
}
func (p *person) TTL() time.Duration {
	return 30 * time.Second
}
func (p *person) String() string {
	return fmt.Sprintf("%s %s (%s)", p.Firstname, p.Lastname, p.EyeColor)
}
func (p *person) MarshalRST(r *http.Request) (string, []byte, error) {
	accept := ParseAccept(r.Header.Get("Accept"))
	if accept.Negotiate(testContentType) == testContentType {
		return testContentType, testCannedBytes, nil
	}
	return MarshalResource(p, r)
}
type resourceCollection []Resource
func (c resourceCollection) Count() uint64 {
	return uint64(len(c))
}
func (c resourceCollection) Units() []string {
	return []string{"bytes", "resources"}
}
func (c resourceCollection) Range(rg *Range) (*ContentRange, Resource, error) {
	return &ContentRange{rg, c.Count()}, c[rg.From : rg.To+1], nil
}
func (c resourceCollection) LastModified() time.Time {
	return testTimeReference
}
func (c resourceCollection) ETag() string {
	if len(c) == 0 {
		return "*"
	}
	return c[0].ETag()
}
func (c resourceCollection) TTL() time.Duration {
	return 15 * time.Second
}
func (c resourceCollection) MarshalRST(r *http.Request) (string, []byte, error) {
	accept := ParseAccept(r.Header.Get("Accept"))
	if accept.Negotiate(testContentType) == testContentType {
		return testContentType, testCannedBytes, nil
	}
	return MarshalResource(c, r)
}
type echoResource struct {
	content []byte
}
func (e *echoResource) MarshalRST(r *http.Request) (string, []byte, error) {
	return "text/plain", e.content, nil
}
func (e *echoResource) LastModified() time.Time {
	return testTimeReference
}
func (e *echoResource) ETag() string {
	return "*"
}
func (e *echoResource) TTL() time.Duration {
	return 0
}
type chunckedEchoResource struct {
	content []byte
}
func (e *chunckedEchoResource) LastModified() time.Time {
	return testTimeReference
}
func (e *chunckedEchoResource) ETag() string {
	return "*"
}
func (e *chunckedEchoResource) TTL() time.Duration {
	return 0
}
func (e *chunckedEchoResource) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	w.Write(e.content)
}
type echoEndpoint struct{}
func (ec *echoEndpoint) Post(vars RouteVars, r *http.Request) (Resource, string, error) {
	c, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return nil, "", err
	}
	defer r.Body.Close()
	return &echoResource{c}, "", nil
}
func (ec *echoEndpoint) Preflight(acReq *AccessControlRequest, vars RouteVars, r *http.Request) *AccessControlResponse {
	return &AccessControlResponse{
		Origin: "preflighted.domain.com",
	}
}
type chunkedEchoEndpoint struct{}
func (ec *chunkedEchoEndpoint) Post(vars RouteVars, r *http.Request) (Resource, string, error) {
	c, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return nil, "", err
	}
	defer r.Body.Close()
	return &chunckedEchoResource{c}, "", nil
}
type panicEndpoint struct{}
func (ep *panicEndpoint) Get(vars RouteVars, r *http.Request) (Resource, error) {
	panic(errors.New("provoked panic"))
}
type peopleCollection struct{}
func (c *peopleCollection) Get(vars RouteVars, r *http.Request) (Resource, error) {
	col := make(resourceCollection, len(testPeople))
	for i, p := range testPeople {
		col[i] = Resource(p)
	}
	if col.Count() == 0 {
		return nil, nil
	}
	return col, nil
}