vcpe/srcs/libs/include/http_svr.h

61 lines
1.4 KiB
C
Raw Normal View History

//
// Created by xajhuang on 2022/11/4.
//
#ifndef VCPE_PROJECT_HTTP_SVR_H
#define VCPE_PROJECT_HTTP_SVR_H
#ifdef __cplusplus
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
}
#endif
2022-12-02 06:42:37 +00:00
#endif //VCPE_PROJECT_HTTP_SVR_H