added web interface to retroshare-gui

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8165 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-04-24 14:31:13 +00:00
parent 1b0f59d746
commit 127c104e5e
16 changed files with 362 additions and 13 deletions

View file

@ -8,6 +8,9 @@
// for filestreamer
#include <retroshare/rsfiles.h>
// to determine default docroot
#include <retroshare/rsinit.h>
#include "JsonStream.h"
#include "ApiServer.h"
@ -58,6 +61,11 @@ struct MHD_Response * MHD_create_response_from_fd(size_t size, int fd)
namespace resource_api{
std::string getDefaultDocroot()
{
return RsAccounts::DataDirectory() + "/webui";
}
const char* API_ENTRY_PATH = "/api/v2";
const char* FILESTREAMER_ENTRY_PATH = "/fstream/";
const char* STATIC_FILES_ENTRY_PATH = "/static/";
@ -509,11 +517,9 @@ int ApiServerMHD::accessHandlerCallback(MHD_Connection *connection,
FILE* fd = fopen(filename.c_str(), "rb");
if(fd == 0)
{
const char *error = "<html><body><p>Error: can't open the requested file.</p></body></html>";
struct MHD_Response* resp = MHD_create_response_from_data(strlen(error), (void*)error, 0, 1);
MHD_add_response_header(resp, "Content-Type", "text/html");
secure_queue_response(connection, MHD_HTTP_NOT_FOUND, resp);
MHD_destroy_response(resp);
#warning sending untrusted string to the browser
std::string msg = "<html><body><p>Error: can't open the requested file. Path is &quot;"+filename+"&quot;</p></body></html>";
sendMessage(connection, MHD_HTTP_NOT_FOUND, msg);
return MHD_YES;
}

View file

@ -14,6 +14,10 @@
namespace resource_api{
class ApiServer;
// returns the default docroot path
// (it is differen on different operating systems)
std::string getDefaultDocroot();
class ApiServerMHD
{
public: