+ else if (mg_match(hm->uri, mg_str("/api/comment/*/*"), caps)) {\r
+ User * user = UsersFind(caps[0]);\r
+ \r
+ if (user != NULL) {\r
+ Post * parent = (Post *)atoll(caps[1].ptr);\r
+ if (parent != NULL) {\r
+ Post newComment;\r
+ newComment.likes = 0;\r
+ newComment.comments = NULL;\r
+ newComment.parent = parent;\r
+ newComment.timestamp = time(NULL);\r
+ newComment.user = user;\r
+ mg_http_get_var(&hm->body, "content", newComment.content, sizeof(newComment.content)-1);\r
+ arrput(parent->comments, newComment);\r
+ }\r
+ }\r
+ }\r
+ else if (mg_match(hm->uri, mg_str("/api/like/*/*"), caps)) {\r
+ User * user = UsersFind(caps[0]);\r
+ if (user != NULL) {\r
+ Post * post = (Post *)atoll(caps[1].ptr);\r
+ if (post != NULL)\r
+ post->likes++;\r
+ }\r
+ }\r
+ else if (mg_match(hm->uri, mg_str("/api/write/*"), caps)) {\r
+ User * user = UsersFind(caps[0]);\r
+ if (user != NULL) {\r
+ char filename[128];\r
+ snprintf(filename, 128, "data/users/%s", user->name);\r
+ FILE * f = fopen(filename, "w");\r
+ UserWrite(user, f);\r
+ fclose(f);\r
+ }\r
+ }\r
+ else if (mg_match(hm->uri, mg_str("/api/read/*"), caps)) {\r
+ User * user = UsersFind(caps[0]);\r
+ if (user != NULL) {\r
+ char filename[128];\r
+ snprintf(filename, 128, "data/users/%s", user->name);\r
+ FILE * f = fopen(filename, "r");\r
+ UserRead(user, f);\r
+ fclose(f);\r
+ }\r
+ }\r
+ http_redirect(c, hm);\r