>>107799810
If I were you I'd put all the api paths in an enum, so you could abstract the route handling to a cleaner switch statement, and leave the parsing of the URL to another function. Something like:
enum route = {
api,
thread,
server
};
Response route(enum route r, char* data)
{
Response response;
switch (r) {
case api:
response = api_render(data);
break;
case thread:
response = thread_render(data);
break;
case server:
response = server_render(data);
break;
default:
response = error(404);
break;
}
return response;
}
Response parse_url(char* url)
{
(tokenize the URL parts and then strcmp them to find the route)
return route(r, data);
}
Ofc you don't HAVE to do it this way but hardcoding the routing to specific strings will make the code a lot harder to maintain. You should also maybe consider lowercasing the URLs during parsing so that someone can access /thread/1 like /Thread/1 if they wanted to