Skip to content

Commit

Permalink
Merge pull request ember-fastboot#124 from bcardarella/feature/bc/exp…
Browse files Browse the repository at this point in the history
…ost-method-and-body

Expose method and body in the Request
  • Loading branch information
tomdale committed Feb 10, 2017
2 parents 52ae12b + 839e3f7 commit 66e1785
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fastboot-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function FastBootRequest(request, hostWhitelist) {
this.headers = new FastBootHeaders(request.headers);
this.queryParams = request.query;
this.path = request.url;
this.method = request.method;
this.body = request.body;

this.cookies = this.extractCookies(request);
}
Expand Down
30 changes: 30 additions & 0 deletions test/fastboot-request-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,34 @@ describe("FastBootRequest", function() {

expect(fastbootRequest.cookies.test).to.equal("bar");
});

it("captures the method from the request", function() {
var request = {
protocol: "http",
url: "/foo",
headers: {
host: "localhost:4200",
cookie: ""
},
method: "GET"
};
var fastbootRequest = new FastBootRequest(request);

expect(fastbootRequest.method).to.equal("GET");
});

it("captures the body from the request", function() {
var request = {
protocol: "http",
url: "/foo",
headers: {
host: "localhost:4200",
cookie: ""
},
body: "TEST"
};
var fastbootRequest = new FastBootRequest(request);

expect(fastbootRequest.body).to.equal("TEST");
});
});

0 comments on commit 66e1785

Please sign in to comment.