解码从Javascript发送到golang服务器的JSON

I can't decode the JSON I get from my JavaScript file (Server handling the requests is written in go)

I've go the following JavaScript Code in order to send a request.

function Connect() {

var data = JSON.stringify({
    Version: "0.1",
    Action: "test",
    Data: {}
});

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
    if (xhr.readyState == XMLHttpRequest.DONE) {
        if(xhr.status >= 200 && xhr.status < 300) {
            console.log(xhr.responseText);
        } else {
            console.warn(xhr);
        }
    }
};
xhr.open("Post", "http://localhost:5252", true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
xhr.send(data);
}

As far as I read this should work in order to send JSON to a server. The requests are received by my server but I fail to decode it.

func newRequestFromJSON(jsonData io.Reader) (*Request, error) {
// Decode the JSON to the request value.
decoder := json.NewDecoder(jsonData)

var r Request
err := decoder.Decode(&r)
if err != nil {
    return nil, e.New(err.Error() + " at " + u.GetFile_line())
}

return &r, nil
}

The Request struct looks the following.

type Request struct {
Version string
Action string
Data interface{}
}

And the io.reader gets the request.body as parameter. The Code works if e.g. I send the same thing with the HttpRequester plugin from firefox.

I get an EOF error and it says that the request is nil. I think that the body of the request is empty, but I'm not sure about that.

What am I missing here?

If someone has the same issue: I finally figured what changes I have to do in my Server to allow such CORS requests.

func init() {
     http.HandleFunc("/", net.HandleRequest)
}

func HandleRequest(rw http.ResponseWriter, req *http.Request) {
// Recover panics and send the error.

if origin := req.Header.Get("Origin"); origin != "" {
    rw.Header().Set("Access-Control-Allow-Origin", origin)
    rw.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
    rw.Header().Set("Access-Control-Allow-Headers",
        "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
}

if req.Method == "OPTIONS" {
    return
}

...(normally handling real request)