commit 7b97e837c0e73aabb4f1691d1414f43eecf4562f
parent 7bdeb39e06b604936e02990becad696d3f82c201
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 26 Apr 2026 22:01:12 +0200
set content language when returning responses from templates
Diffstat:
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/templating/templating_api.c b/src/templating/templating_api.c
@@ -72,7 +72,7 @@ static unsigned int loaded_length;
* (MUST be a 'static' string in memory!)
* @return NULL on error, otherwise the template
*/
-static const char *
+static struct TVE *
lookup_template (struct MHD_Connection *connection,
const char *name)
{
@@ -94,7 +94,7 @@ lookup_template (struct MHD_Connection *connection,
name))
continue; /* does not match by name */
if (NULL == loaded[i].lang) /* no language == always best match */
- return loaded[i].value;
+ return &loaded[i];
q = TALER_pattern_matches (lang,
loaded[i].lang);
if (q < best_q)
@@ -109,7 +109,7 @@ lookup_template (struct MHD_Connection *connection,
name);
return NULL;
}
- return best->value;
+ return best;
}
@@ -242,14 +242,15 @@ TALER_TEMPLATING_build (struct MHD_Connection *connection,
{
char *body;
size_t body_size;
+ struct TVE *tve;
{
const char *tmpl;
int eno;
- tmpl = lookup_template (connection,
- template);
- if (NULL == tmpl)
+ tve = lookup_template (connection,
+ template);
+ if (NULL == tve)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to load template `%s'\n",
@@ -259,6 +260,7 @@ TALER_TEMPLATING_build (struct MHD_Connection *connection,
template);
return GNUNET_NO;
}
+ tmpl = tve->value;
/* Add default values to the context */
if (NULL != instance_id)
{
@@ -323,6 +325,11 @@ TALER_TEMPLATING_build (struct MHD_Connection *connection,
}
}
}
+ if (NULL != tve->lang)
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (*reply,
+ MHD_HTTP_HEADER_CONTENT_LANGUAGE,
+ tve->lang));
/* Add standard headers */
if (NULL != taler_uri)