Skip to content

Commit

Permalink
Merge pull request #953 from T00fy/wip
Browse files Browse the repository at this point in the history
Fixed up json object and added lobbyPort for api response
  • Loading branch information
NotAdam authored May 13, 2024
2 parents 2866e67 + 3bf03c5 commit 989630b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/api/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ void createAccount( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
std::string sId;
if( g_sapphireAPI.createAccount( user, pass, sId ) )
{
// todo: construct proper json object here
std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" +
m_config.global.network.lobbyHost +
"\", \"frontierHost\":\"" +
m_config.global.network.restHost + "\"}";
nlohmann::json response_json = {
{"sId", sId},
{"lobbyHost", m_config.global.network.lobbyHost},
{"frontierHost", m_config.global.network.restHost},
{"lobbyPort", m_config.global.network.lobbyPort}
};

std::string json_string = response_json.dump();
*response << buildHttpResponse( 200, json_string, JSON );
}
else
Expand Down Expand Up @@ -277,12 +279,15 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer:
// reloadConfig();
if( g_sapphireAPI.login( user, pass, sId ) )
{
// todo: build proper json object and stringify it
std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" +
m_config.global.network.lobbyHost +
"\", \"frontierHost\":\"" +
m_config.global.network.restHost + "\"}";
nlohmann::json response_json = {
{"sId", sId},
{"lobbyHost", m_config.global.network.lobbyHost},
{"frontierHost", m_config.global.network.restHost},
{"lobbyPort", m_config.global.network.lobbyPort}
};

std::string json_string = response_json.dump();

*response << buildHttpResponse( 200, json_string, JSON );
}
else
Expand All @@ -294,7 +299,6 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer:
*response << buildHttpResponse( 500 );
Logger::error( e.what() );
}

}

void deleteCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer::Request > request )
Expand Down

0 comments on commit 989630b

Please sign in to comment.