OCT 1. 增加 http 服务相关结构定义
This commit is contained in:
parent
0bbfd2d866
commit
e1b19f4463
|
@ -8,9 +8,51 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
#ifdef HTTPSERVER_ON
|
||||
#include "mongoose.h"
|
||||
|
||||
#define MAX_URI (1024)
|
||||
|
||||
typedef enum {
|
||||
PRI_LOWEASE = 0,
|
||||
PRI_LOW,
|
||||
PRI_NORMAL,
|
||||
PRI_HIGH,
|
||||
PRI_HIGHEST,
|
||||
} HTTP_ROUTE_PRIORITY;
|
||||
|
||||
#define DEF_HTTP_METHOD(HTTP_METHOD) \
|
||||
HTTP_METHOD(GET, "GET") \
|
||||
HTTP_METHOD(POST, "POST") \
|
||||
HTTP_METHOD(PUT, "PUT") \
|
||||
HTTP_METHOD(DELETE, "DELETE") \
|
||||
HTTP_METHOD(HEAD, "HEAD") \
|
||||
HTTP_METHOD(CONNECT, "CONNECT") \
|
||||
HTTP_METHOD(OPTIONS, "OPTIONS") \
|
||||
HTTP_METHOD(TRACE, "TRACE") \
|
||||
HTTP_METHOD(PATCH, "PATCH")
|
||||
|
||||
#define GENERATE_HTTP_METHOD_ENUM(ENUM, x) ENUM,
|
||||
|
||||
typedef enum {
|
||||
DEF_HTTP_METHOD(GENERATE_HTTP_METHOD_ENUM)
|
||||
} HTTP_METHOD;
|
||||
|
||||
typedef struct {
|
||||
int httpCode;
|
||||
int errCode;
|
||||
const char* pRspHeads;
|
||||
void *pRspData;
|
||||
} HTTP_RSP_CTX, *PHTTP_RSP_CTX;
|
||||
|
||||
typedef void (*HTTP_REQUEST_CB)(struct mg_http_message *, void *, PHTTP_RSP_CTX);
|
||||
|
||||
int http_svr_init();
|
||||
|
||||
int http_svr_uinit();
|
||||
int http_add_route(const char *path,
|
||||
HTTP_METHOD method,
|
||||
HTTP_ROUTE_PRIORITY priority,
|
||||
HTTP_REQUEST_CB cb,
|
||||
void *pUserData);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue