cp_http_service_create(3) - Linux man page
Name
cp_http_service - http service descriptor
Synopsis
#include <cprops/http.h>
cp_http_service *
- cp_http_service_create(char *name, char *path,
cp_http_service_callback service);
void cp_http_service_delete(cp_http_service *service);
Description
With the libcprops http server socket api, defining services is done by wrapping handler functions for specific uri prefixes in a cp_http_service struct and registered with a cp_httpsocket. The service function should follow this prototype:
-
int service(cp_http_request *request, cp_http_response *response);
- and return one of the integer values HTTP_CONNECTION_POLICY_CLOSE or HTTP_CONNECTION_POLICY_KEEP_ALIVE as required per request. For each
request the service function registered to handle the request uri prefix is invoked with a request wrapper describing the request and an empty
response wrapper which will be written to the remote client when the service handler returns.
cp_http_service_create creates a service with the name name, uri prefix path and service handler service. cp_http_service_delete finalizes a service descriptor struct.
cp_httpsocket_register_service associates a service with a cp_httpsocket. Services may be associated with multiple socket instances.
See Also
cp_httpsocket(3), cp_http_request(3), cp_http_response(3)