libexpress 0.0.1
Express Server Framework in C
|
This contains all the request related material. More...
#include <libhmap/hmap.h>
#include <libqueue/queue.h>
Go to the source code of this file.
Data Structures | |
struct | req_t |
Request made by client. More... | |
Functions | |
req_t * | parse_req (char *req_str, int size) |
Parses the HTTP request string sent by client. More... | |
char * | get_req_body (req_t *req) |
Get the body of request. More... | |
char * | get_req_header (req_t *req, const char *header) |
Get a particular header from the request. More... | |
char * | get_req_method (req_t *req) |
Get the method of the request. More... | |
char * | get_req_param (req_t *req, const char *param) |
Get the value of a particular request path parameter. More... | |
char * | get_req_path (req_t *req) |
Get the path of the request. More... | |
char * | get_req_query (req_t *req, const char *query) |
Get a particular query from the request. More... | |
This contains all the request related material.
char * get_req_body | ( | req_t * | req | ) |
Get the body of request.
req | Request |
char * get_req_header | ( | req_t * | req, |
const char * | header | ||
) |
Get a particular header from the request.
req | Request |
header | Header key |
char * get_req_method | ( | req_t * | req | ) |
Get the method of the request.
req | Request |
char * get_req_param | ( | req_t * | req, |
const char * | param | ||
) |
Get the value of a particular request path parameter.
The key (param
) is set according to the route you're calling this function in. If the route is for path /hello/:id/world, then something like /hello/abcd/world will populate the param "id" with the value "abcd".
req | Request |
param | Name of the param, as used by the route. |
char * get_req_path | ( | req_t * | req | ) |
Get the path of the request.
It gives the path requested by the client, minus any queries.
If the request by client is for /hello?search=world&foo=bar
then the path is /hello
req | Request |
char * get_req_query | ( | req_t * | req, |
const char * | query | ||
) |
Get a particular query from the request.
If the request by client is for /hello?search=world&foo=bar
then the queries are as follows:
search = world foo = bar
in the form of key = value
req | |
query |
req_t * parse_req | ( | char * | req_str, |
int | size | ||
) |
Parses the HTTP request string sent by client.
It parses the HTTP request string sent by the client and gives a req_t
Request that contains all the information from the request in a meaningful manner.
req_str | HTTP Request String of the client |
size | No. of bytes (string length) of the request string |