libexpress 0.0.1
Express Server Framework in C
Loading...
Searching...
No Matches
req.h
Go to the documentation of this file.
1
8#ifndef __LIBEXPRESS_REQ_H
9#define __LIBEXPRESS_REQ_H 1
10
11/* Personal Libraries */
12#include <libhmap/hmap.h>
13#include <libqueue/queue.h>
14
21typedef struct {
22 char *method;
23 char *path;
24 hmap_t *queries; // queries like /hello?query1=value1&query2=value2
25 hmap_t *headers;
26 hmap_t *params; // params like /person/1234abcde
27 char *body;
28 queue_t *c_queue; //controller queue, includes middlewares as well
29} req_t;
30
42req_t* parse_req(char *req_str, int size);
43
44/* Utility */
45
52char* get_req_body(req_t* req);
53
61char* get_req_header(req_t* req, const char* header);
62
69char* get_req_method(req_t* req);
70
82char* get_req_param(req_t* req, const char* param);
83
95char* get_req_path(req_t* req);
96
112char* get_req_query(req_t* req, const char* query);
113
114// TODO: Add instructions in docs for iterating through maps
115
116#endif
char * get_req_param(req_t *req, const char *param)
Get the value of a particular request path parameter.
Definition: req.c:157
char * get_req_path(req_t *req)
Get the path of the request.
Definition: req.c:163
char * get_req_header(req_t *req, const char *header)
Get a particular header from the request.
Definition: req.c:145
char * get_req_method(req_t *req)
Get the method of the request.
Definition: req.c:151
char * get_req_query(req_t *req, const char *query)
Get a particular query from the request.
Definition: req.c:169
req_t * parse_req(char *req_str, int size)
Parses the HTTP request string sent by client.
Definition: req.c:6
char * get_req_body(req_t *req)
Get the body of request.
Definition: req.c:139
Request made by client.
Definition: req.h:21