mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-21 21:05:05 +00:00
New file mastoapi.c.
This commit is contained in:
parent
74817a4552
commit
353e393f4d
4 changed files with 32 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ CFLAGS?=-g -Wall
|
||||||
all: snac
|
all: snac
|
||||||
|
|
||||||
snac: snac.o main.o data.o http.o httpd.o webfinger.o \
|
snac: snac.o main.o data.o http.o httpd.o webfinger.o \
|
||||||
activitypub.o html.o utils.o format.o upgrade.o
|
activitypub.o html.o utils.o format.o upgrade.o mastoapi.o
|
||||||
$(CC) $(CFLAGS) -L/usr/local/lib *.o -lcurl -lcrypto -pthread $(LDFLAGS) -o $@
|
$(CC) $(CFLAGS) -L/usr/local/lib *.o -lcurl -lcrypto -pthread $(LDFLAGS) -o $@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
|
|
4
httpd.c
4
httpd.c
|
@ -185,6 +185,10 @@ void httpd_connection(FILE *f)
|
||||||
status = activitypub_post_handler(req, q_path,
|
status = activitypub_post_handler(req, q_path,
|
||||||
payload, p_size, &body, &b_size, &ctype);
|
payload, p_size, &body, &b_size, &ctype);
|
||||||
|
|
||||||
|
if (status == 0)
|
||||||
|
status = mastoapi_post_handler(req, q_path,
|
||||||
|
payload, p_size, &body, &b_size, &ctype);
|
||||||
|
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
status = html_post_handler(req, q_path,
|
status = html_post_handler(req, q_path,
|
||||||
payload, p_size, &body, &b_size, &ctype);
|
payload, p_size, &body, &b_size, &ctype);
|
||||||
|
|
24
mastoapi.c
Normal file
24
mastoapi.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* snac - A simple, minimalistic ActivityPub instance */
|
||||||
|
/* copyright (c) 2022 - 2023 grunfink / MIT license */
|
||||||
|
|
||||||
|
#include "xs.h"
|
||||||
|
#include "xs_encdec.h"
|
||||||
|
#include "xs_json.h"
|
||||||
|
#include "xs_time.h"
|
||||||
|
|
||||||
|
#include "snac.h"
|
||||||
|
|
||||||
|
int mastoapi_post_handler(xs_dict *req, char *q_path, char *payload, int p_size,
|
||||||
|
char **body, int *b_size, char **ctype)
|
||||||
|
{
|
||||||
|
int status = 404;
|
||||||
|
|
||||||
|
if (!xs_startswith(q_path, "/api/v1/"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
xs *j = xs_json_dumps_pp(req, 4);
|
||||||
|
printf("%s\n", j);
|
||||||
|
printf("%s\n", payload);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
3
snac.h
3
snac.h
|
@ -223,3 +223,6 @@ int resetpwd(snac *snac);
|
||||||
int job_fifo_ready(void);
|
int job_fifo_ready(void);
|
||||||
void job_post(const xs_val *job, int urgent);
|
void job_post(const xs_val *job, int urgent);
|
||||||
void job_wait(xs_val **job);
|
void job_wait(xs_val **job);
|
||||||
|
|
||||||
|
int mastoapi_post_handler(xs_dict *req, char *q_path, char *payload, int p_size,
|
||||||
|
char **body, int *b_size, char **ctype);
|
||||||
|
|
Loading…
Reference in a new issue