1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-10-18 00:54:25 +00:00

implement display and serving of archived artifacts

This commit is contained in:
Oliver Giles
2015-09-19 17:24:20 +02:00
parent dbc75000a5
commit a729a6782e
6 changed files with 71 additions and 2 deletions

View File

@@ -168,7 +168,17 @@ public:
wss.set_http_handler([this](websocketpp::connection_hdl hdl){
websocket::connection_ptr c = wss.get_con_from_hdl(hdl);
const char* start, *end;
if(resources.handleRequest(c->get_resource(), &start, &end)) {
std::string resource = c->get_resource();
if(resource.compare(0, strlen("/archive/"), "/archive/") == 0) {
std::string file(resource.substr(strlen("/archive/")));
std::string content;
if(laminar.getArtefact(file, content)) {
c->set_status(websocketpp::http::status_code::ok);
c->set_body(content);
} else {
c->set_status(websocketpp::http::status_code::not_found);
}
} else if(resources.handleRequest(resource, &start, &end)) {
c->set_status(websocketpp::http::status_code::ok);
c->append_header("Content-Encoding", "gzip");
c->set_body(std::string(start, end));