comparison OrthancServer/Sources/LuaScripting.cpp @ 4605:c8f444e8556d

new function in the plugin SDK: OrthancPluginCallRestApi()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Mar 2021 16:34:02 +0200
parents b4c58795f3a8
children d01702fb29a9
comparison
equal deleted inserted replaced
4597:b7fe3494a53c 4605:c8f444e8556d
403 LuaContext::GetDictionaryArgument(headers, state, 3, true /* HTTP header key to lower case */); 403 LuaContext::GetDictionaryArgument(headers, state, 3, true /* HTTP header key to lower case */);
404 404
405 try 405 try
406 { 406 {
407 std::string result; 407 std::string result;
408 if (IHttpHandler::SimpleGet(result, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), 408 if (IHttpHandler::SimpleGet(result, NULL, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin),
409 RequestOrigin_Lua, uri, headers)) 409 RequestOrigin_Lua, uri, headers) == HttpStatus_200_Ok)
410 { 410 {
411 lua_pushlstring(state, result.c_str(), result.size()); 411 lua_pushlstring(state, result.c_str(), result.size());
412 return 1; 412 return 1;
413 } 413 }
414 } 414 }
456 456
457 try 457 try
458 { 458 {
459 std::string result; 459 std::string result;
460 if (isPost ? 460 if (isPost ?
461 IHttpHandler::SimplePost(result, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), 461 IHttpHandler::SimplePost(result, NULL,
462 RequestOrigin_Lua, uri, bodyData, bodySize, headers) : 462 serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin),
463 IHttpHandler::SimplePut(result, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), 463 RequestOrigin_Lua, uri, bodyData, bodySize, headers) == HttpStatus_200_Ok :
464 RequestOrigin_Lua, uri, bodyData, bodySize, headers)) 464 IHttpHandler::SimplePut(result, NULL,
465 serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin),
466 RequestOrigin_Lua, uri, bodyData, bodySize, headers) == HttpStatus_200_Ok)
465 { 467 {
466 lua_pushlstring(state, result.c_str(), result.size()); 468 lua_pushlstring(state, result.c_str(), result.size());
467 return 1; 469 return 1;
468 } 470 }
469 } 471 }
520 std::map<std::string, std::string> headers; 522 std::map<std::string, std::string> headers;
521 LuaContext::GetDictionaryArgument(headers, state, 3, true /* HTTP header key to lower case */); 523 LuaContext::GetDictionaryArgument(headers, state, 3, true /* HTTP header key to lower case */);
522 524
523 try 525 try
524 { 526 {
525 if (IHttpHandler::SimpleDelete(serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), 527 if (IHttpHandler::SimpleDelete(NULL, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin),
526 RequestOrigin_Lua, uri, headers)) 528 RequestOrigin_Lua, uri, headers) == HttpStatus_200_Ok)
527 { 529 {
528 lua_pushboolean(state, 1); 530 lua_pushboolean(state, 1);
529 return 1; 531 return 1;
530 } 532 }
531 } 533 }