mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:25:11 +00:00
[ADD/WIP] Routerwerk!
This commit is contained in:
parent
25ed114d0f
commit
47c98cbbe3
8 changed files with 280 additions and 1 deletions
45
src/include/Parsee.h
Normal file
45
src/include/Parsee.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef PARSEE_PARSEE_H
|
||||
#define PARSEE_PARSEE_H
|
||||
|
||||
#include <Cytoplasm/HttpServer.h>
|
||||
#include <Cytoplasm/HttpRouter.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;
|
||||
} 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 *);
|
||||
#endif
|
||||
20
src/include/Routes.h
Normal file
20
src/include/Routes.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef PARSEE_ROUTES_H
|
||||
#define PARSEE_ROUTES_H
|
||||
|
||||
#include <Parsee.h>
|
||||
typedef struct ParseeHttpArg {
|
||||
ParseeData *data;
|
||||
HttpServerContext *ctx;
|
||||
Stream *stream;
|
||||
} ParseeHttpArg;
|
||||
|
||||
/* A list of all routes. */
|
||||
#define ROUTES X_ROUTE("/", RouteRoot)
|
||||
|
||||
#define X_ROUTE(path, name) extern void * name(Array *, void *);
|
||||
ROUTES
|
||||
#undef X_ROUTE
|
||||
|
||||
#define RouteHead(name, pathargs, argp) void * \
|
||||
name(Array * pathargs, void *argp)
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue