@@ -19,7 +19,7 @@ var Route = require('./router/route');
1919var Router = require ( './router' ) ;
2020var req = require ( './request' ) ;
2121var res = require ( './response' ) ;
22-
22+ var isHttp2Supported = require ( './utils' ) . isHttp2Supported ;
2323/**
2424 * Expose `createApplication()`.
2525 */
@@ -34,23 +34,36 @@ exports = module.exports = createApplication;
3434 */
3535
3636function createApplication ( ) {
37- var app = function ( req , res , next ) {
37+ var app = function ( req , res , next ) {
3838 app . handle ( req , res , next ) ;
3939 } ;
4040
4141 mixin ( app , EventEmitter . prototype , false ) ;
4242 mixin ( app , proto , false ) ;
4343
4444 // expose the prototype that will get set on requests
45- app . request = Object . create ( req , {
45+ app . request = Object . create ( req . req , {
4646 app : { configurable : true , enumerable : true , writable : true , value : app }
4747 } )
4848
4949 // expose the prototype that will get set on responses
50- app . response = Object . create ( res , {
50+ app . response = Object . create ( res . res , {
5151 app : { configurable : true , enumerable : true , writable : true , value : app }
5252 } )
5353
54+ if ( isHttp2Supported ) {
55+ app . http2Request = Object . create ( req . http2Req , {
56+ app : { configurable : true , enumerable : true , writable : true , value : app }
57+ } ) ;
58+
59+ app . http2Response = Object . create ( res . http2Res , {
60+ app : { configurable : true , enumerable : true , writable : true , value : app }
61+ } ) ;
62+ }
63+
64+
65+
66+
5467 app . init ( ) ;
5568 return app ;
5669}
0 commit comments