File 6803-inets-Add-callback-attributes-to-mod_esi.patch of Package erlang
From 21b47a0fc8ad0d4aaca5923b7000179d4b635de8 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 27 Sep 2023 16:18:15 +0200
Subject: [PATCH 3/5] inets: Add callback attributes to mod_esi
---
lib/inets/doc/src/mod_esi.xml | 4 ++--
lib/inets/src/http_server/mod_esi.erl | 34 +++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/lib/inets/doc/src/mod_esi.xml b/lib/inets/doc/src/mod_esi.xml
index 5f992303e9..5a86530a04 100644
--- a/lib/inets/doc/src/mod_esi.xml
+++ b/lib/inets/doc/src/mod_esi.xml
@@ -61,7 +61,7 @@
<tag><c>{server_port, integer()}</c></tag>
<item><p>Servers port number.</p></item>
- <tag><c>{request_method, "GET | "PUT" | "DELETE" | "POST" | "PATCH"}</c></tag>
+ <tag><c>{request_method, "GET" | "PUT" | "DELETE" | "POST" | "PATCH"}</c></tag>
<item><p>HTTP request method.</p></item>
<tag><c>{remote_adress, inet:ip_address()} </c></tag>
@@ -127,7 +127,7 @@
to the server process by calling <c>mod_esi:deliver/2</c>.</fsummary>
<type>
<v>SessionID = term()</v>
- <v>Env = env()</v>
+ <v>Env = [env()]</v>
<v>Input = string() | chunked_data()</v>
<v>chunked_data() = {first, Data::binary()} |
{continue, Data::binary(), State::term()} |
diff --git a/lib/inets/src/http_server/mod_esi.erl b/lib/inets/src/http_server/mod_esi.erl
index 8e42311d00..cc8f23adbd 100644
--- a/lib/inets/src/http_server/mod_esi.erl
+++ b/lib/inets/src/http_server/mod_esi.erl
@@ -39,6 +39,40 @@
[{status, {404, ModData#mod.request_uri, "Not found"}} |
ModData#mod.data]).
+%%%=========================================================================
+%%% Types
+%%%=========================================================================
+-type env() :: {server_software, string()} |
+ {server_name, string()} |
+ {gateway_interface, string()} |
+ {server_protocol, string()} |
+ {server_port, integer()} |
+ {request_method, string() } |
+ {remote_adress, inet:ip_address()} |
+ {peer_cert, undefined | no_peercert | public_key:der_encoded()} |
+ {script_name, string()} |
+ {http_LowerCaseHTTPHeaderName, string()}.
+
+%%%=========================================================================
+%%% Callbacks
+%%%=========================================================================
+-callback 'Function'(SessionID, Env, Input) -> {continue, State} | _
+ when
+ SessionID :: term(),
+ Env :: [env()],
+ Input :: string() | ChunkedData,
+ ChunkedData ::
+ {first, Data :: binary()} |
+ {continue,
+ Data :: binary(),
+ State :: term()} |
+ {last,
+ Data :: binary(),
+ State :: term()},
+ State :: term().
+
+-optional_callbacks(['Function'/3]).
+
%%%=========================================================================
%%% API
%%%=========================================================================
--
2.35.3