mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-26 10:11:30 +00:00
Added KIWIX_RESPONSE_DATA to error response
Now the data used to generate an error response can be made to be embedded in the response as a JS object KIWIX_RESPONSE_DATA.
This commit is contained in:
@ -29,7 +29,8 @@ TEST(HTTPErrorResponse, shouldBeInEnglishByDefault) {
|
||||
HTTPErrorResponse errResp(req, MHD_HTTP_NOT_FOUND,
|
||||
"404-page-title",
|
||||
"404-page-heading",
|
||||
"/css/error.css");
|
||||
"/css/error.css",
|
||||
/*includeKiwixResponseData=*/true);
|
||||
|
||||
EXPECT_EQ(getResponseContent(errResp),
|
||||
R"(<!DOCTYPE html>
|
||||
@ -38,6 +39,9 @@ R"(<!DOCTYPE html>
|
||||
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
|
||||
<title>Content not found</title>
|
||||
<link type="text/css" href="/css/error.css" rel="Stylesheet" />
|
||||
<script>
|
||||
const KIWIX_RESPONSE_DATA = { "CSS_URL" : "/css/error.css", "PAGE_HEADING" : { "msgid" : "404-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "404-page-title", "params" : { } }, "details" : [ ] };
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Not Found</h1>
|
||||
@ -56,7 +60,8 @@ TEST(HTTPErrorResponse, shouldBeTranslatable) {
|
||||
HTTPErrorResponse errResp(req, MHD_HTTP_NOT_FOUND,
|
||||
"404-page-title",
|
||||
"404-page-heading",
|
||||
"/css/error.css");
|
||||
"/css/error.css",
|
||||
/*includeKiwixResponseData=*/true);
|
||||
|
||||
EXPECT_EQ(getResponseContent(errResp),
|
||||
R"(<!DOCTYPE html>
|
||||
@ -65,6 +70,9 @@ R"(<!DOCTYPE html>
|
||||
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
|
||||
<title>[I18N TESTING] Not Found - Try Again</title>
|
||||
<link type="text/css" href="/css/error.css" rel="Stylesheet" />
|
||||
<script>
|
||||
const KIWIX_RESPONSE_DATA = { "CSS_URL" : "/css/error.css", "PAGE_HEADING" : { "msgid" : "404-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "404-page-title", "params" : { } }, "details" : [ ] };
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>[I18N TESTING] Content not found, but at least the server is alive</h1>
|
||||
|
Reference in New Issue
Block a user