func (p *Router) ServeRequest(ctx context.Context, req server.Request, rsp server.Response) error {
	if p.Name == "" {
		p.Name = DefaultName
	}
	if p.Client == nil {
		p.Client = client.DefaultClient
	}
	if req.Service() == p.Name {
		return server.DefaultRouter.ServeRequest(ctx, req, rsp)
	}
	opts := []client.CallOption{}
	service := req.Service()
	endpoint := req.Endpoint()
	if len(p.Backend) > 0 {
		if parts := strings.Split(p.Backend, ":"); len(parts) > 0 {
			opts = append(opts, client.WithAddress(p.Backend))
		} else {
			service = p.Backend
		}
	}
	if len(p.Endpoint) > 0 {
		endpoint = p.Endpoint
	}
	body, err := req.Read()
	if err != nil {
		return err
	}
	creq := p.Client.NewRequest(service, endpoint, &bytes.Frame{body}, client.WithContentType(req.ContentType()))
	stream, err := p.Client.Stream(ctx, creq, opts...)
	if err != nil {
		return err
	}
	defer stream.Close()
	go readLoop(req, stream)
	resp := stream.Response()
	for {
		body, err := resp.Read()
		if err == io.EOF {
			return nil
		} else if err != nil {
			return err
		}
		hdr := resp.Header()
		rsp.WriteHeader(hdr)
		err = rsp.Write(body)
		if err == io.EOF {
			return nil
		} else if err != nil {
			return err
		}
	}
	return nil
}
ServeRequest honours the server.Router interface
package mucp
import (
	"context"
	"io"
	"strings"
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/client"
	"github.com/micro/go-micro/codec"
	"github.com/micro/go-micro/codec/bytes"
	"github.com/micro/go-micro/server"
)
type Router struct {
	Name string
	Backend string
	Endpoint string
	Client client.Client
}
var (
	DefaultName = "go.micro.proxy"
	DefaultRouter = &Router{}
)
func readLoop(r server.Request, s client.Stream) error {
	req := s.Request()
	for {
		body, err := r.Read()
		if err == io.EOF {
			return nil
		}
		if err != nil {
			return err
		}
		hdr := r.Header()
		msg := &codec.Message{
			Type:   codec.Request,
			Header: hdr,
			Body:   body,
		}
		err = req.Codec().Write(msg, nil)
		if err == io.EOF {
			return nil
		} else if err != nil {
			return err
		}
	}
}