wip
This commit is contained in:
@@ -57,16 +57,6 @@ static bool initialized = false;
|
||||
*/
|
||||
int _restd_log_level = RESTD_LOG_WARN;
|
||||
|
||||
/*
|
||||
* User callback hook container.
|
||||
*/
|
||||
typedef struct restd_hook_s restd_hook_t;
|
||||
struct restd_hook_s
|
||||
{
|
||||
char *method;
|
||||
restd_callback cb;
|
||||
void *userdata;
|
||||
};
|
||||
|
||||
/*
|
||||
* Local functions.
|
||||
@@ -686,6 +676,20 @@ static void conn_cb(restd_conn_t *conn, int event)
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void restd_server_register_request_handler(restd_server_t *server, restd_callback cb)
|
||||
{
|
||||
server->request_handler = cb;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void restd_server_register_error_handler(restd_server_t *server, restd_callback cb)
|
||||
{
|
||||
server->error_handler = cb;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Register user hook.
|
||||
*/
|
||||
@@ -700,10 +704,18 @@ void restd_server_register_hook(restd_server_t *server, restd_callback cb, void
|
||||
* Register user hook on method name.
|
||||
*/
|
||||
void restd_server_register_hook_on_method(restd_server_t *server, const char *method, restd_callback cb, void *userdata)
|
||||
{
|
||||
restd_server_register_hook_on_path(server, method, NULL, cb, userdata);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void restd_server_register_hook_on_path(restd_server_t *server, const char *method, const char *path, restd_callback cb, void *userdata)
|
||||
{
|
||||
restd_hook_t hook;
|
||||
bzero((void *)&hook, sizeof(restd_hook_t));
|
||||
hook.method = (method) ? strdup(method) : NULL;
|
||||
hook.path = (path) ? strdup(path) : NULL;
|
||||
hook.cb = cb;
|
||||
hook.userdata = userdata;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user