Parsee/src/include/Parsee.h
LDA 0fa95c2d14 [ADD/WIP] Add some HTTP request code
We can now *register* users!
2024-06-13 09:35:57 +02:00

55 lines
1.5 KiB
C

#ifndef PARSEE_PARSEE_H
#define PARSEE_PARSEE_H
#include <Cytoplasm/HttpServer.h>
#include <Cytoplasm/HttpRouter.h>
#include <Cytoplasm/HttpClient.h>
#include <Cytoplasm/Stream.h>
typedef struct ParseeConfig {
char *as_token, *hs_token;
/* id here is "Parsee XMPP". */
char *sender_localpart;
char *namespace_base;
char *listen_as;
int port;
/* Homeserver port info */
char *homeserver_host;
int homeserver_port;
} ParseeConfig;
typedef struct ParseeData {
const ParseeConfig *config;
HttpRouter *router;
} ParseeData;
/* Initialises a Parsee config from scratch, and writes to it
* as JSON in the CWD. */
extern void ParseeConfigInit(void);
/* Loads a Parsee config from a JSON filepath. */
extern void ParseeConfigLoad(char *);
/* Retrieves the Parsee config if loaded. */
extern const ParseeConfig * ParseeConfigGet(void);
/* Exports the Parsee config as a YAML document. */
extern void ParseeExportConfigYAML(Stream *);
/* Destroys the Parsee configuration */
extern void ParseeConfigFree(void);
/* Creates and destroys a data structure, stored on the heap. */
extern ParseeData * ParseeInitData(void);
extern void ParseeFreeData(ParseeData *);
/* HTTP server handler for Parsee, takes in a config. */
extern void ParseeRequest(HttpServerContext *, void *);
extern HttpClientContext * ParseeCreateRequest(ParseeConfig *, HttpRequestMethod, char *);
/* Sends headers, and writes the JSON object. */
extern HttpStatus ParseeSetRequestJSON(HttpClientContext *, HashMap *);
#endif