MediaProcessors
Macros | Functions
procs_api_http.c File Reference
#include "procs_api_http.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <libcjson/cJSON.h>
#include <libmediaprocsutils/uri_parser.h>
#include <libmediaprocsutils/log.h>
#include <libmediaprocsutils/stat_codes.h>
#include <libmediaprocsutils/check_utils.h>
#include "procs.h"
Include dependency graph for procs_api_http.c:

Go to the source code of this file.

Macros

#define RESPONSE_FMT   "{\"code\":%d,\"status\":%s,\"message\":%s,\"data\":%s}"
 
#define URL_HAS(NEEDLE)   (url!= NULL && strstr(url, NEEDLE)!= NULL)
 
#define URL_METHOD_IS(TAG)
 
#define HTTP_OK   "\"OK\""
 
#define HTTP_CREATED   "\"Created\""
 
#define HTTP_NOCONTENT   "\"No Content\""
 
#define HTTP_NOTFOUND   "\"Not Found\""
 
#define HTTP_NOTMODIF   "\"Not Modified\""
 
#define HTTP_CREATED   "\"Created\""
 
#define HTTP_CONFLICT   "\"Conflict\""
 

Functions

int procs_api_http_req_handler (procs_ctx_t *procs_ctx, const char *url, const char *query_string, const char *request_method, char *content, size_t content_len, char **ref_str_response)
 

Detailed Description

Author
Rafael Antoniello

Definition in file procs_api_http.c.

Macro Definition Documentation

#define HTTP_OK   "\"OK\""

HTTP status textual

Definition at line 70 of file procs_api_http.c.

#define RESPONSE_FMT   "{\"code\":%d,\"status\":%s,\"message\":%s,\"data\":%s}"

JSON wrapped response format; is as follows: { "code":number, "status":string, "message":string, "data": {...} // object returned by PROCS if any or null. }

Definition at line 52 of file procs_api_http.c.

#define URL_HAS (   NEEDLE)    (url!= NULL && strstr(url, NEEDLE)!= NULL)

Returns non-zero if given URL string contains 'needle' sub-string.

Definition at line 57 of file procs_api_http.c.

#define URL_METHOD_IS (   TAG)
Value:
(request_method!= NULL && \
strncmp(request_method, TAG, strlen(TAG))== 0)

Compares given required method string description.

Definition at line 63 of file procs_api_http.c.

Function Documentation

int procs_api_http_req_handler ( procs_ctx_t procs_ctx,
const char *  url,
const char *  query_string,
const char *  request_method,
char *  content,
size_t  content_len,
char **  ref_str_response 
)

HTTP-API request handler function.

Parameters
procs_ctx
url
query_string
request_method
content
content_len
ref_str_responseReference to the pointer to a character string returning the representational state associated with this request.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 82 of file procs_api_http.c.