Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 880 Bytes

iterating_query_params.md

File metadata and controls

31 lines (24 loc) · 880 Bytes

Iterating over Query Parameters

To iterate through parameters, the object CwebDict may be used like this:

#include "CWebStudioOne.c"
CwebNamespace cweb;

CwebHttpResponse *main_sever(CwebHttpRequest *request ){

    CwebDict *query_paramns = request->params;
    for(int i = 0; i < query_paramns->size; i++){
        CwebKeyVal *key_val = query_paramns->keys_vals[i];
        char *key = key_val->key;
        char *value = key_val->value;
        printf("%s : %s\n", key, value);
    }
    printf("------------------------------------------\n");
    return cweb.response.send_text("Hello World", 200);

}

int main(int argc, char *argv[]){
    cweb = newCwebNamespace();
    CwebServer server = newCwebSever(5000, main_sever);
    cweb.server.start(&server);
    return 0;
}

This example demonstrates how to iterate through all query parameters in the request.