Skip to content

Commit 66e1785

Browse files
authored
Merge pull request #124 from bcardarella/feature/bc/expost-method-and-body
Expose method and body in the Request
2 parents 52ae12b + 839e3f7 commit 66e1785

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/fastboot-request.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ function FastBootRequest(request, hostWhitelist) {
88
this.headers = new FastBootHeaders(request.headers);
99
this.queryParams = request.query;
1010
this.path = request.url;
11+
this.method = request.method;
12+
this.body = request.body;
1113

1214
this.cookies = this.extractCookies(request);
1315
}

test/fastboot-request-test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,34 @@ describe("FastBootRequest", function() {
134134

135135
expect(fastbootRequest.cookies.test).to.equal("bar");
136136
});
137+
138+
it("captures the method from the request", function() {
139+
var request = {
140+
protocol: "http",
141+
url: "/foo",
142+
headers: {
143+
host: "localhost:4200",
144+
cookie: ""
145+
},
146+
method: "GET"
147+
};
148+
var fastbootRequest = new FastBootRequest(request);
149+
150+
expect(fastbootRequest.method).to.equal("GET");
151+
});
152+
153+
it("captures the body from the request", function() {
154+
var request = {
155+
protocol: "http",
156+
url: "/foo",
157+
headers: {
158+
host: "localhost:4200",
159+
cookie: ""
160+
},
161+
body: "TEST"
162+
};
163+
var fastbootRequest = new FastBootRequest(request);
164+
165+
expect(fastbootRequest.body).to.equal("TEST");
166+
});
137167
});

0 commit comments

Comments
 (0)