Beispiel #1
0
void server_answerRequest(http_request_t request, socket_t* client, leading_t** leadings){
    puts(request.method);
    puts(request.uri);
    if(!strcmp(request.uri, "/")){
        server_homepage(client);
    }
    else if(!strcmp(request.uri, "/leadings") || !strcmp(request.uri, "/leadings/")){
        server_sendLeadingsHTML(client, leadings);
    }
    else if(strncmp(request.uri, "/api/leadings/", 13) == 0){
        if(!strcmp(request.method, "GET")){
            server_getByIdJSON(request, client, leadings);
        }
        else if(!strcmp(request.method, "DELETE")){
            server_deleteByIdJSON(request, client, leadings);
        }
        else if(!strcmp(request.method, "POST")){
            server_post(request, client, leadings);
        }
    }
    else if(!strcmp(request.uri, "/api/leadings") || !strcmp(request.uri, "/api/leadings/")){
        server_sendLeadingsJSON(client, leadings);
    }
    else if(!strcmp(request.uri, "/leadings/new/") || !strcmp(request.uri, "/leadings/new")){
        server_postHTML(client, leadings);
    }
    else if(strncmp(request.uri, "/leadings/delete/", 16) == 0){
        server_deleteByIdHTML(request, client, leadings);
    }
    else if(strncmp(request.uri, "/leadings/", 9) == 0){
        server_getByIdHTML(request, client, leadings);
    }

    else server_notFound(client);
}
Beispiel #2
0
void server_answerRequest(http_request_t request, socket_t* client, db_t* base)
{
    puts(request.method);
    puts(request.uri);
    if(!strcmp(request.uri, "/"))
    {
        server_homepage(client);
    }
    else if(!strcmp(request.uri, "/workers") || !strcmp(request.uri, "/workers/"))
    {
        server_sendWorkersHTML(client, base);
    }
    else if(strncmp(request.uri, "/api/workers/", 13) == 0)
    {
        if(!strcmp(request.method, "POST"))
        {
            server_post(request, client, base);
        }
        else if(!strcmp(request.method, "GET"))
        {
            server_getByIdJSON(request, client, base);
        }
        else if(!strcmp(request.method, "DELETE"))
        {
            server_deleteByIdJSON(request, client, base);
        }
    }
    if(!strcmp(request.uri, "/api/workers") || !strcmp(request.uri, "/api/workers/"))
    {
        server_sendWorkersJSON(client, base);
    }
    else if(strstr(request.uri, "/api/workers/") == NULL && strstr(request.uri, "/api/workers") != NULL)
    {
        server_personalTask(request, client, base);
    }
    else if(!strcmp(request.uri, "/workers/new/") || !strcmp(request.uri, "/workers/new"))
    {
        server_postHTML(client);
    }
    else if(strncmp(request.uri, "/workers/delete/", 16) == 0)
    {
        server_deleteByIdHTML(request, client, base);
    }
    else if(strncmp(request.uri, "/workers/", 9) == 0)
    {
        server_getByIdHTML(request, client, base);
    }

    else server_notFound(client);
}