From be8aaeeba7c7bbdac1035342c1b181ae88fe6b52 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Fri, 18 Jan 2019 15:56:08 +0100 Subject: [PATCH] Wrap all http methods & all SSL options --- src/AppWrapper.h | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/AppWrapper.h b/src/AppWrapper.h index 3c24b5d7..66d8ba12 100644 --- a/src/AppWrapper.h +++ b/src/AppWrapper.h @@ -184,6 +184,7 @@ void uWS_App(const FunctionCallbackInfo &args) { static std::string keyFileName; static std::string certFileName; static std::string passphrase; + static std::string dhParamsFileName; /* Read the options object (SSL options) */ if (args.Length() == 1) { @@ -207,6 +208,13 @@ void uWS_App(const FunctionCallbackInfo &args) { passphrase.append(passphraseValue.getData(), passphraseValue.getLength()); ssl_options.passphrase = passphrase.c_str(); } + + /* DH params file name */ + NativeString dhParamsFileNameValue(isolate, Local::Cast(args[0])->Get(String::NewFromUtf8(isolate, "dh_params_file_name"))); + if (dhParamsFileNameValue.getLength()) { + dhParamsFileName.append(dhParamsFileNameValue.getData(), dhParamsFileNameValue.getLength()); + ssl_options.dh_params_file_name = dhParamsFileName.c_str(); + } } app = new APP(ssl_options); @@ -217,7 +225,7 @@ void uWS_App(const FunctionCallbackInfo &args) { appTemplate->InstanceTemplate()->SetInternalFieldCount(1); - /* get, post */ + /* All the http methods */ appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "get"), FunctionTemplate::New(isolate, [](auto &args) { uWS_App_get(&APP::get, args); })); @@ -226,16 +234,43 @@ void uWS_App(const FunctionCallbackInfo &args) { uWS_App_get(&APP::post, args); })); + appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "options"), FunctionTemplate::New(isolate, [](auto &args) { + uWS_App_get(&APP::options, args); + })); + + appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "del"), FunctionTemplate::New(isolate, [](auto &args) { + uWS_App_get(&APP::del, args); + })); + + appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "patch"), FunctionTemplate::New(isolate, [](auto &args) { + uWS_App_get(&APP::patch, args); + })); + + appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "put"), FunctionTemplate::New(isolate, [](auto &args) { + uWS_App_get(&APP::put, args); + })); + + appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "head"), FunctionTemplate::New(isolate, [](auto &args) { + uWS_App_get(&APP::head, args); + })); + + appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "connect"), FunctionTemplate::New(isolate, [](auto &args) { + uWS_App_get(&APP::connect, args); + })); + + appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "trace"), FunctionTemplate::New(isolate, [](auto &args) { + uWS_App_get(&APP::trace, args); + })); + + /* What about unhandled? */ + /* ws, listen */ appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "ws"), FunctionTemplate::New(isolate, uWS_App_ws)); appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "listen"), FunctionTemplate::New(isolate, uWS_App_listen)); + // appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "free"), FunctionTemplate::New(isolate, uWS_App_free)); - // Instantiate and set intenal pointer Local localApp = appTemplate->GetFunction()->NewInstance(isolate->GetCurrentContext()).ToLocalChecked(); - - // Delete this boy localApp->SetAlignedPointerInInternalField(0, app); - // Return an instance of this shit args.GetReturnValue().Set(localApp); }