122 lines
2.8 KiB
C
122 lines
2.8 KiB
C
|
#define flecs_components_http_STATIC
|
||
|
#ifndef FLECS_COMPONENTS_HTTP_H
|
||
|
#define FLECS_COMPONENTS_HTTP_H
|
||
|
|
||
|
/*
|
||
|
)
|
||
|
(.)
|
||
|
.|.
|
||
|
| |
|
||
|
_.--| |--._
|
||
|
.-'; ;`-'& ; `&.
|
||
|
\ & ; & &_/
|
||
|
|"""---...---"""|
|
||
|
\ | | | | | | | /
|
||
|
`---.|.|.|.---'
|
||
|
|
||
|
* This file is generated by bake.lang.c for your convenience. Headers of
|
||
|
* dependencies will automatically show up in this file. Include bake_config.h
|
||
|
* in your main project file. Do not edit! */
|
||
|
|
||
|
#ifndef FLECS_COMPONENTS_HTTP_BAKE_CONFIG_H
|
||
|
#define FLECS_COMPONENTS_HTTP_BAKE_CONFIG_H
|
||
|
|
||
|
/* Headers of public dependencies */
|
||
|
#include <flecs.h>
|
||
|
#include <flecs_meta.h>
|
||
|
|
||
|
/* Convenience macro for exporting symbols */
|
||
|
#ifndef flecs_components_http_STATIC
|
||
|
#if flecs_components_http_EXPORTS && (defined(_MSC_VER) || defined(__MINGW32__))
|
||
|
#define FLECS_COMPONENTS_HTTP_API __declspec(dllexport)
|
||
|
#elif flecs_components_http_EXPORTS
|
||
|
#define FLECS_COMPONENTS_HTTP_API __attribute__((__visibility__("default")))
|
||
|
#elif defined _MSC_VER
|
||
|
#define FLECS_COMPONENTS_HTTP_API __declspec(dllimport)
|
||
|
#else
|
||
|
#define FLECS_COMPONENTS_HTTP_API
|
||
|
#endif
|
||
|
#else
|
||
|
#define FLECS_COMPONENTS_HTTP_API
|
||
|
#endif
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|
||
|
ECS_ENUM(EcsHttpMethod, {
|
||
|
EcsHttpGet,
|
||
|
EcsHttpPost,
|
||
|
EcsHttpPut,
|
||
|
EcsHttpDelete,
|
||
|
EcsHttpMethodUnknown
|
||
|
});
|
||
|
|
||
|
struct EcsHttpEndpoint;
|
||
|
|
||
|
typedef struct EcsHttpRequest {
|
||
|
const char *url;
|
||
|
const char *relative_url;
|
||
|
const char *params;
|
||
|
void *ctx;
|
||
|
EcsHttpMethod method;
|
||
|
ecs_entity_t server;
|
||
|
} EcsHttpRequest;
|
||
|
|
||
|
ECS_STRUCT(EcsHttpReply, {
|
||
|
char *header;
|
||
|
char *body;
|
||
|
int status;
|
||
|
bool is_file;
|
||
|
});
|
||
|
|
||
|
typedef bool (*EcsHttpServiceAction)(
|
||
|
ecs_world_t *world,
|
||
|
ecs_entity_t entity,
|
||
|
struct EcsHttpEndpoint *endpoint,
|
||
|
EcsHttpRequest *request,
|
||
|
EcsHttpReply *reply);
|
||
|
|
||
|
ECS_STRUCT(EcsHttpServer, {
|
||
|
uint16_t port;
|
||
|
});
|
||
|
|
||
|
ECS_STRUCT(EcsHttpEndpoint, {
|
||
|
char *url;
|
||
|
void *ctx;
|
||
|
bool synchronous;
|
||
|
|
||
|
ECS_PRIVATE
|
||
|
EcsHttpServiceAction action;
|
||
|
});
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
typedef struct FlecsComponentsHttp {
|
||
|
ECS_DECLARE_COMPONENT(EcsHttpServer);
|
||
|
ECS_DECLARE_COMPONENT(EcsHttpEndpoint);
|
||
|
} FlecsComponentsHttp;
|
||
|
|
||
|
FLECS_COMPONENTS_HTTP_API
|
||
|
void FlecsComponentsHttpImport(
|
||
|
ecs_world_t *world);
|
||
|
|
||
|
/* Utility to get parameter from query string */
|
||
|
FLECS_COMPONENTS_HTTP_API
|
||
|
size_t ecs_http_get_query_param(
|
||
|
const char *query,
|
||
|
const char *name,
|
||
|
char *buffer,
|
||
|
size_t len);
|
||
|
|
||
|
#define FlecsComponentsHttpImportHandles(handles)\
|
||
|
ECS_IMPORT_COMPONENT(handles, EcsHttpServer);\
|
||
|
ECS_IMPORT_COMPONENT(handles, EcsHttpEndpoint);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif
|