libexpress 0.0.1
Express Server Framework in C
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
router.h File Reference

This contains the router functions. More...

#include <libvector/vector.h>
#include "controller.h"
#include "util.h"

Go to the source code of this file.

Data Structures

struct  route_t
 Route. More...
 
struct  router_t
 Router. More...
 

Macros

#define MID_END   NULL
 A macro that defines the end of the middlewares in a router. More...
 

Typedefs

typedef u_int16_t port_t
 Port number.
 
typedef router_t server_t
 

Functions

route_tfind_route (router_t *router, req_t *req)
 Finds the router most appropriate for serving request. More...
 
void route (router_t *router, const char *path, char *method,...)
 Assign Route for a specific method for a specific path. More...
 
void route_get (router_t *router, const char *path,...)
 Assign a route for GET request for a router. More...
 
void route_post (router_t *router, const char *path,...)
 Assign a route for POST request for a router. More...
 
void route_put (router_t *router, const char *path,...)
 Assign a route for PUT request for a router. More...
 
void route_delete (router_t *router, const char *path,...)
 Assign a route for DELETE request for a router. More...
 

Detailed Description

This contains the router functions.

It contains and imports all the functions of router that are made available.

Author
Saurav Pal (resyfer)
Bug:
No known bugs

Macro Definition Documentation

◆ MID_END

#define MID_END   NULL

A macro that defines the end of the middlewares in a router.

It defines the end of the middlewares in a route and is to be used as a parameter before the final controller.

Function Documentation

◆ find_route()

route_t * find_route ( router_t router,
req_t req 
)

Finds the router most appropriate for serving request.

Parameters
routerRouter
reqRequest Instance
Returns
route_t* Route

◆ route()

void route ( router_t router,
const char *  path,
char *  method,
  ... 
)

Assign Route for a specific method for a specific path.

Parameters
routerRouter instance, can be server instance as well
pathPath for router, only part of it which should be it's path if the tree of router hierarchy is maintained
methodThe method of the HTTP requests
...Any number of controllers or middlewares of the type controller_t*

◆ route_delete()

void route_delete ( router_t router,
const char *  path,
  ... 
)

Assign a route for DELETE request for a router.

Parameters
routerRouter instance, can be server instance as well
pathPath for router, only part of it which should be it's path if the tree of router hierarchy is maintained
...Any number of controllers or middlewares of the type controller_t*

◆ route_get()

void route_get ( router_t router,
const char *  path,
  ... 
)

Assign a route for GET request for a router.

Parameters
routerRouter instance, can be server instance as well
pathPath for router, only part of it which should be it's path if the tree of router hierarchy is maintained
...Any number of controllers or middlewares of the type controller_t*

◆ route_post()

void route_post ( router_t router,
const char *  path,
  ... 
)

Assign a route for POST request for a router.

Parameters
routerRouter instance, can be server instance as well
pathPath for router, only part of it which should be it's path if the tree of router hierarchy is maintained
...Any number of controllers or middlewares of the type controller_t*

◆ route_put()

void route_put ( router_t router,
const char *  path,
  ... 
)

Assign a route for PUT request for a router.

Parameters
routerRouter instance, can be server instance as well
pathPath for router, only part of it which should be it's path if the tree of router hierarchy is maintained
...Any number of controllers or middlewares of the type controller_t*