Skip to content

Commit

Permalink
Node.js: add getResponsePrototype, getRequestPrototype again
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Hultman committed Feb 20, 2017
1 parent 891a5fc commit e94b6e1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nodejs/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,22 @@ struct HttpServer {
}
}

static void getResponsePrototype(const FunctionCallbackInfo<Value> &args) {
args.GetReturnValue().Set(Local<Object>::New(args.GetIsolate(), resTemplate)->GetPrototype());
}

static void getRequestPrototype(const FunctionCallbackInfo<Value> &args) {
args.GetReturnValue().Set(Local<Object>::New(args.GetIsolate(), reqTemplate)->GetPrototype());
}

static Local<Function> getHttpServer(Isolate *isolate) {
Local<FunctionTemplate> httpServer = FunctionTemplate::New(isolate, HttpServer::createServer);
httpServer->InstanceTemplate()->SetInternalFieldCount(1);

httpServer->Set(String::NewFromUtf8(isolate, "createServer"), FunctionTemplate::New(isolate, HttpServer::createServer));
httpServer->Set(String::NewFromUtf8(isolate, "getExpressApp"), FunctionTemplate::New(isolate, HttpServer::getExpressApp));
httpServer->Set(String::NewFromUtf8(isolate, "getResponsePrototype"), FunctionTemplate::New(isolate, HttpServer::getResponsePrototype));
httpServer->Set(String::NewFromUtf8(isolate, "getRequestPrototype"), FunctionTemplate::New(isolate, HttpServer::getRequestPrototype));
httpServer->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "listen"), FunctionTemplate::New(isolate, HttpServer::listen));
httpServer->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "on"), FunctionTemplate::New(isolate, HttpServer::on));

Expand Down

0 comments on commit e94b6e1

Please sign in to comment.