func (c *Client) RequestAPI(de rpc.Deserializer, req interface{}, session string, route Route) error {
	p, err := json.Marshal(req)
	if err != nil {
		return fmt.Errorf("failed to marshal request body %s", err.Error())
	}
	res, err := c.Request(Request{
		Route: route,
		Body:  p,
		Headers: map[string]string{
			insecure.HeaderKey:           "mykey",
			auth.RequestHeaderSessionKey: session,
			"Content-type":               "application/json",
		},
	})
	if err != nil {
		return err
	}
	if res.Code == http.StatusNoContent {
		return nil
	}
	if res.Code != http.StatusOK {
		if len(res.Body) > 0 {
			var rpcError rpc.Error
			if err := json.Unmarshal(res.Body, &rpcError); err != nil {
				return fmt.Errorf("failed to unmarshal response body as error %s", err.Error())
			}
			return &rpcError
		}
		return &rpc.HttpError{Cause: nil, StatusCode: res.Code}
	}
	if err := de.Deserialize(bytes.NewBuffer(res.Body)); err != nil {
		return fmt.Errorf("failed to unmarshal response body %s", err.Error())
	}
	return nil
}
RequestAPI performs a request to the API
package apitest
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	auth "github.com/oasislabs/oasis-gateway/auth/core"
	"github.com/oasislabs/oasis-gateway/auth/insecure"
	"github.com/oasislabs/oasis-gateway/rpc"
)
func NewClient(router *rpc.HttpRouter) *Client {
	return &Client{
		router: router,
	}
}
type Client struct {
	router *rpc.HttpRouter
}
func (c *Client) Request(req Request) (Response, error) {
	httpRequest, err := c.createHTTPRequest(req)
	if err != nil {
		return Response{}, err
	}
	for key, value := range req.Headers {
		httpRequest.Header.Add(key, value)
	}
	httpResponse := httptest.NewRecorder()
	c.router.ServeHTTP(httpResponse, httpRequest)
	p, err := ioutil.ReadAll(httpResponse.Body)
	if err != nil {
		return Response{}, err
	}
	return Response{
		Code: httpResponse.Code,
		Body: p,
	}, nil
}