DeterministicESPAsyncWebServer
v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
webhook.h
Go to the documentation of this file.
1
// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2
// SPDX-License-Identifier: AGPL-3.0-or-later
3
4
/**
5
* @file webhook.h
6
* @brief Outbound webhooks / IFTTT (DETWS_ENABLE_WEBHOOK).
7
*
8
* Builds an IFTTT Maker webhook URL and its value1/value2/value3 JSON payload
9
* (pure, host-tested), and fires them - or any JSON to any URL - via the outbound
10
* http_client (a POST). Lets the device push an event to IFTTT, a Slack/Discord
11
* incoming webhook, or your own REST endpoint. Needs DETWS_ENABLE_HTTP_CLIENT to
12
* send; without it the API still compiles but detws_webhook_post() returns -1.
13
*
14
* @author Douglas Quigg (dstroy0)
15
* @date 2026
16
*/
17
18
#ifndef DETERMINISTICESPASYNCWEBSERVER_WEBHOOK_H
19
#define DETERMINISTICESPASYNCWEBSERVER_WEBHOOK_H
20
21
#include "
ServerConfig.h
"
22
#include <stddef.h>
23
24
#if DETWS_ENABLE_WEBHOOK
25
26
// ---------------------------------------------------------------------------
27
// Host-testable builders
28
// ---------------------------------------------------------------------------
29
30
/**
31
* @brief Build the IFTTT Maker URL `https://maker.ifttt.com/trigger/<event>/with/key/<key>`.
32
* @return characters written, or 0 if it would not fit @p cap (fail-closed).
33
*/
34
int
detws_ifttt_url(
const
char
*event,
const
char
*key,
char
*out,
size_t
cap);
35
36
/**
37
* @brief Build an IFTTT `{"value1":..,"value2":..,"value3":..}` JSON body.
38
*
39
* Null values are omitted; values are JSON-escaped for `"` and `\`. An all-null
40
* call yields `{}`.
41
* @return characters written, or 0 if it would not fit @p cap (fail-closed).
42
*/
43
int
detws_ifttt_payload(
const
char
*v1,
const
char
*v2,
const
char
*v3,
char
*out,
size_t
cap);
44
45
// ---------------------------------------------------------------------------
46
// Fire (ESP32 via http_client; HTTP_CLIENT_ERR_* on host)
47
// ---------------------------------------------------------------------------
48
49
/** @brief POST @p json (application/json) to @p url. @return HTTP status (>0) or negative error. */
50
int
detws_webhook_post(
const
char
*url,
const
char
*json);
51
52
/**
53
* @brief Trigger an IFTTT Maker event with up to three values.
54
* @return HTTP status (>0) or a negative error (e.g. URL/payload build or transport).
55
*/
56
int
detws_ifttt_trigger(
const
char
*event,
const
char
*key,
const
char
*v1,
const
char
*v2,
const
char
*v3);
57
58
#endif
// DETWS_ENABLE_WEBHOOK
59
#endif
// DETERMINISTICESPASYNCWEBSERVER_WEBHOOK_H
ServerConfig.h
User-facing configuration for DeterministicESPAsyncWebServer.
src
services
webhook
webhook.h
Generated by
1.9.8