Mercurial > hg > orthanc
comparison OrthancServer/LuaScripting.cpp @ 1445:d26c8a93d05a
refactoring: SimpleGet
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 01 Jul 2015 12:30:19 +0200 |
parents | b2b09a3dbd8e |
children | 5ba7471780ae |
comparison
equal
deleted
inserted
replaced
1444:b2b09a3dbd8e | 1445:d26c8a93d05a |
---|---|
80 } | 80 } |
81 | 81 |
82 const char* uri = lua_tostring(state, 1); | 82 const char* uri = lua_tostring(state, 1); |
83 bool builtin = (nArgs == 2 ? lua_toboolean(state, 2) : false); | 83 bool builtin = (nArgs == 2 ? lua_toboolean(state, 2) : false); |
84 | 84 |
85 IHttpHandler& handler = (builtin ? | 85 std::string result; |
86 serverContext->GetHttpHandler().GetOrthancRestApi() : | 86 if (HttpToolbox::SimpleGet(result, serverContext->GetHttpHandler().RestrictToOrthancRestApi(builtin), uri)) |
87 serverContext->GetHttpHandler()); | 87 { |
88 | 88 lua_pushstring(state, result.c_str()); |
89 std::string str; | |
90 if (HttpToolbox::SimpleGet(str, handler, uri)) | |
91 { | |
92 lua_pushstring(state, str.c_str()); | |
93 } | 89 } |
94 else | 90 else |
95 { | 91 { |
96 LOG(ERROR) << "Lua: Error in RestApiGet() for URI " << uri; | 92 LOG(ERROR) << "Lua: Error in RestApiGet() for URI " << uri; |
97 lua_pushnil(state); | 93 lua_pushnil(state); |