libexpress 0.0.1
Express Server Framework in C
Loading...
Searching...
No Matches
router.h
Go to the documentation of this file.
1
12#ifndef __ROUTER_LIBEXPRESS_H
13#define __ROUTER_LIBEXPRESS_H 1
14
15/* Personal Libraries */
16#include <libvector/vector.h>
17
18/* Header Includes */
19#include "controller.h"
20#include "util.h"
21
25typedef u_int16_t port_t;
26
34typedef struct {
35 vector_t *middlewares;
36 controller_t* controller;
37} route_t;
38
45#define MID_END NULL
46
58typedef struct {
59 char *path;
60 hmap_t *routes; /* Of type route_t */
61 hmap_t *child_routers; /* Of type router_t */
62} router_t;
63typedef router_t server_t;
64
65// TODO:
66// router_t* router_new(server_t *server, char *path);
67// void router_use(router_t *router, char *path, middleware_t middleware);
68
76route_t* find_route(router_t *router, req_t *req);
77
87void route(router_t *router, const char *path, char* method, ...);
88
97void route_get(router_t *router, const char *path, ...);
98
107void route_post(router_t *router, const char *path, ...);
108
117void route_put(router_t *router, const char *path, ...);
118
127void route_delete(router_t *router, const char *path, ...);
128
129#endif
This contains all the controller related material.
void route_delete(router_t *router, const char *path,...)
Assign a route for DELETE request for a router.
Definition: router.c:368
route_t * find_route(router_t *router, req_t *req)
Finds the router most appropriate for serving request.
Definition: router.c:144
void route(router_t *router, const char *path, char *method,...)
Assign Route for a specific method for a specific path.
Definition: router.c:284
void route_put(router_t *router, const char *path,...)
Assign a route for PUT request for a router.
Definition: router.c:347
void route_post(router_t *router, const char *path,...)
Assign a route for POST request for a router.
Definition: router.c:326
u_int16_t port_t
Port number.
Definition: router.h:25
void route_get(router_t *router, const char *path,...)
Assign a route for GET request for a router.
Definition: router.c:305
Request made by client.
Definition: req.h:21
Route.
Definition: router.h:34
Router.
Definition: router.h:58
This contains all the utilities used through the library.