Ulfius
HTTP Framework for REST Applications in C
Functions
struct _u_endpoint

Functions

int ulfius_add_endpoint (struct _u_instance *u_instance, const struct _u_endpoint *u_endpoint)
 
int ulfius_add_endpoint_by_val (struct _u_instance *u_instance, const char *http_method, const char *url_prefix, const char *url_format, unsigned int priority, int(*callback_function)(const struct _u_request *request, struct _u_response *response, void *user_data), void *user_data)
 
int ulfius_add_endpoint_list (struct _u_instance *u_instance, const struct _u_endpoint **u_endpoint_list)
 
int ulfius_remove_endpoint (struct _u_instance *u_instance, const struct _u_endpoint *u_endpoint)
 
int ulfius_set_default_endpoint (struct _u_instance *u_instance, int(*callback_function)(const struct _u_request *request, struct _u_response *response, void *user_data), void *user_data)
 
int ulfius_remove_endpoint_by_val (struct _u_instance *u_instance, const char *http_method, const char *url_prefix, const char *url_format)
 
const struct _u_endpointulfius_empty_endpoint (void)
 
int ulfius_copy_endpoint (struct _u_endpoint *dest, const struct _u_endpoint *source)
 
struct _u_endpointulfius_duplicate_endpoint_list (const struct _u_endpoint *endpoint_list)
 
void ulfius_clean_endpoint (struct _u_endpoint *endpoint)
 
void ulfius_clean_endpoint_list (struct _u_endpoint *endpoint_list)
 
int ulfius_equals_endpoints (const struct _u_endpoint *endpoint1, const struct _u_endpoint *endpoint2)
 

Detailed Description

struct _u_endpoint management functions

Function Documentation

◆ ulfius_add_endpoint()

int ulfius_add_endpoint ( struct _u_instance u_instance,
const struct _u_endpoint u_endpoint 
)

Add a struct _u_endpoint * to the specified u_instance Can be done during the execution of the webservice for injection

Parameters
u_instancepointer to a struct _u_instance that describe its port and bind address
u_endpointpointer to a struct _u_endpoint that will be copied in the u_instance endpoint_list
Returns
U_OK on success

◆ ulfius_add_endpoint_by_val()

int ulfius_add_endpoint_by_val ( struct _u_instance u_instance,
const char *  http_method,
const char *  url_prefix,
const char *  url_format,
unsigned int  priority,
int(*)(const struct _u_request *request, struct _u_response *response, void *user_data)  callback_function,
void *  user_data 
)

Add a struct _u_endpoint * to the specified u_instance with its values specified Can be done during the execution of the webservice for injection

Parameters
u_instancepointer to a struct _u_instance that describe its port and bind address
http_methodhttp verb (GET, POST, PUT, etc.) in upper case
url_prefixprefix for the url (optional)
url_formatstring used to define the endpoint format separate words with / to define a variable in the url, prefix it with @ or : example: /test/resource/:name/elements on an url_format that ends with '*', the rest of the url will not be tested
priorityendpoint priority in descending order (0 is the higher priority)
callback_functiona pointer to a function that will be executed each time the endpoint is called you must declare the function as described.
user_dataa pointer to a data or a structure that will be available in callback_function
Returns
U_OK on success

◆ ulfius_add_endpoint_list()

int ulfius_add_endpoint_list ( struct _u_instance u_instance,
const struct _u_endpoint **  u_endpoint_list 
)

Add a struct _u_endpoint * list to the specified u_instance Can be done during the execution of the webservice for injection

Parameters
u_instancepointer to a struct _u_instance that describe its port and bind address
u_endpoint_listpointer to an array of struct _u_endpoint ending with a ulfius_empty_endpoint() that will be copied in the u_instance endpoint_list
Returns
U_OK on success

◆ ulfius_remove_endpoint()

int ulfius_remove_endpoint ( struct _u_instance u_instance,
const struct _u_endpoint u_endpoint 
)

Remove a struct _u_endpoint * from the specified u_instance Can be done during the execution of the webservice for injection

Parameters
u_instancepointer to a struct _u_instance that describe its port and bind address
u_endpointpointer to a struct _u_endpoint that will be removed in the u_instance endpoint_list The parameters _u_endpoint.http_method, _u_endpoint.url_prefix and _u_endpoint.url_format are strictly compared for the match If no endpoint is found, return U_ERROR_NOT_FOUND
Returns
U_OK on success

◆ ulfius_set_default_endpoint()

int ulfius_set_default_endpoint ( struct _u_instance u_instance,
int(*)(const struct _u_request *request, struct _u_response *response, void *user_data)  callback_function,
void *  user_data 
)

ulfius_set_default_endpoint Set the default endpoint This endpoint will be called if no endpoint match the url called

Parameters
u_instancepointer to a struct _u_instance that describe its port and bind address
callback_functiona pointer to a function that will be executed each time the endpoint is called you must declare the function as described.
user_dataa pointer to a data or a structure that will be available in callback_function to remove a default endpoint, call ulfius_set_default_endpoint with NULL parameter for callback_function
Returns
U_OK on success

◆ ulfius_remove_endpoint_by_val()

int ulfius_remove_endpoint_by_val ( struct _u_instance u_instance,
const char *  http_method,
const char *  url_prefix,
const char *  url_format 
)

Remove a struct _u_endpoint * from the specified u_instance using the specified values used to identify an endpoint Can be done during the execution of the webservice for injection The parameters _u_endpoint.http_method, _u_endpoint.url_prefix and _u_endpoint.url_format are strictly compared for the match If no endpoint is found, return U_ERROR_NOT_FOUND

Parameters
u_instancepointer to a struct _u_instance that describe its port and bind address
http_methodhttp_method used by the endpoint
url_prefixurl_prefix used by the endpoint
url_formaturl_format used by the endpoint
Returns
U_OK on success

◆ ulfius_empty_endpoint()

const struct _u_endpoint* ulfius_empty_endpoint ( void  )

ulfius_empty_endpoint

Returns
empty endpoint that goes at the end of an endpoint list

◆ ulfius_copy_endpoint()

int ulfius_copy_endpoint ( struct _u_endpoint dest,
const struct _u_endpoint source 
)

ulfius_copy_endpoint makes a copy of an endpoint with duplicate values

Parameters
destthe endpoint destination
sourcethe endpoint source
Returns
U_OK on success

ulfius_copy_endpoint return a copy of an endpoint with duplicate values

◆ ulfius_duplicate_endpoint_list()

struct _u_endpoint* ulfius_duplicate_endpoint_list ( const struct _u_endpoint endpoint_list)

u_copy_endpoint_list makes a copy of an endpoint list with duplicate values

Parameters
endpoint_listan array of struct _u_endpoint * finishing with a ulfius_empty_endpoint()
Returns
a list with duplicate values returned value must be free'd after use

duplicate_endpoint_list return a copy of an endpoint list with duplicate values returned value must be free'd after use

◆ ulfius_clean_endpoint()

void ulfius_clean_endpoint ( struct _u_endpoint endpoint)

ulfius_clean_endpoint free allocated memory by an endpoint

Parameters
endpointthe endpoint to cleanup

clean_endpoint free allocated memory by an endpoint

◆ ulfius_clean_endpoint_list()

void ulfius_clean_endpoint_list ( struct _u_endpoint endpoint_list)

ulfius_clean_endpoint_list free allocated memory by an endpoint list

Parameters
endpoint_listthe list of endpoints to cleanup, finishing with a ulfius_empty_endpoint()

ulfius_clean_endpoint_list free allocated memory by an endpoint list

◆ ulfius_equals_endpoints()

int ulfius_equals_endpoints ( const struct _u_endpoint endpoint1,
const struct _u_endpoint endpoint2 
)

ulfius_equals_endpoints Compare 2 endpoints

Parameters
endpoint1the first endpoint to compare
endpoint2the second endpoint to compare
Returns
true if their method, prefix and format are the same or if both are NULL, false otherwise