2015-05-25 21:36:40 +02:00
|
|
|
#ifndef _HTTP_H_
|
|
|
|
#define _HTTP_H_
|
|
|
|
|
2015-08-04 01:08:42 +02:00
|
|
|
#ifndef DISABLE_HTTP
|
2015-09-24 22:47:14 +02:00
|
|
|
#include <jansson.h>
|
2015-05-25 21:36:40 +02:00
|
|
|
#include "../common.h"
|
|
|
|
|
2015-11-08 23:03:35 +01:00
|
|
|
typedef struct {
|
|
|
|
const char *method;
|
|
|
|
const char *url;
|
|
|
|
const json_t *body;
|
|
|
|
} http_json_request;
|
|
|
|
|
2015-05-25 21:36:40 +02:00
|
|
|
typedef struct {
|
|
|
|
int status_code;
|
|
|
|
json_t *root;
|
|
|
|
} http_json_response;
|
|
|
|
|
2015-11-08 23:03:35 +01:00
|
|
|
#define HTTP_METHOD_GET "GET"
|
|
|
|
#define HTTP_METHOD_POST "POST"
|
|
|
|
#define HTTP_METHOD_PUT "PUT"
|
|
|
|
#define HTTP_METHOD_DELETE "DELETE"
|
|
|
|
|
|
|
|
http_json_response *http_request_json(const http_json_request *request);
|
|
|
|
void http_request_json_async(const http_json_request *request, void (*callback)(http_json_response*));
|
2015-05-25 21:36:40 +02:00
|
|
|
void http_request_json_dispose(http_json_response *response);
|
2015-08-04 01:08:42 +02:00
|
|
|
#endif // DISABLE_HTTP
|
|
|
|
|
|
|
|
// These callbacks are defined anyway, but are dummy if HTTP is disabled
|
|
|
|
void http_init();
|
|
|
|
void http_dispose();
|
2015-05-25 21:36:40 +02:00
|
|
|
|
|
|
|
#endif
|