mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:58:59 +02:00
cleanup checking of request method, clarify that node is being deleted
This commit is contained in:
parent
d85c0bb88a
commit
f6c9c57585
1 changed files with 79 additions and 69 deletions
|
@ -49,15 +49,10 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
|||
const char RESPONSE_400[] = "HTTP/1.0 400 Bad Request\r\n\r\n";
|
||||
|
||||
const char ASSIGNMENT_URI[] = "/assignment";
|
||||
const char NODE_URI[] = "/node";
|
||||
|
||||
if (strcmp(ri->uri, "/assignment") == 0 && strcmp(ri->request_method, "POST") == 0) {
|
||||
// return a 200
|
||||
mg_printf(connection, "%s", RESPONSE_200);
|
||||
// upload the file
|
||||
mg_upload(connection, "/tmp");
|
||||
|
||||
return 1;
|
||||
} else if (strcmp(ri->uri, "/assignments.json") == 0) {
|
||||
if (strcmp(ri->request_method, "GET") == 0) {
|
||||
if (strcmp(ri->uri, "/assignments.json") == 0) {
|
||||
// user is asking for json list of assignments
|
||||
|
||||
// start with a 200 response
|
||||
|
@ -123,13 +118,28 @@ int DomainServer::civetwebRequestHandler(struct mg_connection *connection) {
|
|||
|
||||
// we've processed this request
|
||||
return 1;
|
||||
}
|
||||
|
||||
// not processed, pass to document root
|
||||
return 0;
|
||||
} else if (strcmp(ri->request_method, "POST") == 0) {
|
||||
if (strcmp(ri->uri, ASSIGNMENT_URI) == 0) {
|
||||
// return a 200
|
||||
mg_printf(connection, "%s", RESPONSE_200);
|
||||
// upload the file
|
||||
mg_upload(connection, "/tmp");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} else if (strcmp(ri->request_method, "DELETE") == 0) {
|
||||
// this is a DELETE request
|
||||
|
||||
// check if it is for an assignment
|
||||
if (memcmp(ri->uri, ASSIGNMENT_URI, sizeof(ASSIGNMENT_URI) - sizeof('\0')) == 0) {
|
||||
if (memcmp(ri->uri, NODE_URI, strlen(NODE_URI)) == 0) {
|
||||
// pull the UUID from the url
|
||||
QUuid deleteUUID = QUuid(QString(ri->uri + strlen(ASSIGNMENT_URI) + sizeof('/')));
|
||||
QUuid deleteUUID = QUuid(QString(ri->uri + strlen(NODE_URI) + sizeof('/')));
|
||||
|
||||
if (!deleteUUID.isNull()) {
|
||||
Node *nodeToKill = NodeList::getInstance()->nodeWithUUID(deleteUUID);
|
||||
|
|
Loading…
Reference in a new issue