func (h *httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if r.Method != http.MethodPost {
		http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
		return
	}
	w.Header().Set("Content-Type", "application/json")
	h.server.ServeCodec(jsonrpc.NewServerCodec(&serverCodec{r.Body, w}))
}
ServeHTTP implements an http.Handler that answers RPC requests.
package jsonrpc
import (
	"io"
	"net/http"
	"net/rpc"
	"net/rpc/jsonrpc"
)
type serverCodec struct {
	r io.ReadCloser  
	w io.Writer      
}
func (s *serverCodec) Read(p []byte) (n int, err error) {
	return s.r.Read(p)
}
func (s *serverCodec) Write(p []byte) (n int, err error) {
	return s.w.Write(p)
}
func (s *serverCodec) Close() error {
	return s.r.Close()
}
func Handler(server *rpc.Server) http.Handler {
	return &httpHandler{server}
}
type httpHandler struct {
	server *rpc.Server
}