Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New way of building 404 error HTML responses #732

Merged
merged 20 commits into from
Mar 28, 2022
Merged

Conversation

veloman-yunkan
Copy link
Collaborator

@veloman-yunkan veloman-yunkan commented Mar 24, 2022

This is the next step on our path to internationalizing kiwix-serve (and making #679 a smaller PR).

The main goal of this PR was to introduce a new eDSL like way of building error responses. Here it is done only for 404 HTML error responses. A couple of further generalizations still remain in #679 because those enhancements were a little too dependent (factually but not conceptually) on the changes related to the internationalization of kiwix-serve.

@codecov
Copy link

codecov bot commented Mar 24, 2022

Codecov Report

Merging #732 (ec2e10b) into master (941c3b5) will increase coverage by 0.48%.
The diff coverage is 93.02%.

@@            Coverage Diff             @@
##           master     #732      +/-   ##
==========================================
+ Coverage   57.83%   58.31%   +0.48%     
==========================================
  Files          56       56              
  Lines        3652     3697      +45     
  Branches     2048     2069      +21     
==========================================
+ Hits         2112     2156      +44     
- Misses       1539     1540       +1     
  Partials        1        1              
Impacted Files Coverage Δ
src/server/internalServer_catalog_v2.cpp 95.00% <50.00%> (ø)
src/server/internalServer.cpp 81.19% <85.18%> (-0.10%) ⬇️
src/opds_dumper.cpp 98.30% <100.00%> (-0.02%) ⬇️
src/server/response.cpp 87.94% <100.00%> (+1.65%) ⬆️
src/server/response.h 100.00% <100.00%> (ø)
src/tools/otherTools.cpp 83.03% <100.00%> (+0.46%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 941c3b5...ec2e10b. Read the comment docs.

This was referenced Mar 24, 2022
This was done in preparation for removing the `bookName` and `bookTitle`
parameters from `Response::build_404()`, but since the new function
could already be put to some use in this commit that was done too.
Instead of passing the `bookName` and `bookTitle` parameters to
`Response::build_404()`, `withTaskbarInfo()` is applied to its result
when needed. Note, that in `InternalServer::handle_raw()`
`withTaskbarInfo()` was not utilized since the results of the `/raw`
endpoint are not supposed to be decorated with a taskbar.
The fact that an info message was moved into C++ code is temporary
since it will be moved to a message resource file soon.
After this change it's time to say thank you and good-bye to
`withTaskbarInfo()`. But it will take a while.
One more instance of `Response::build_404()` & `withTaskbarInfo()`
was taken over by `HTTP404HtmlResponse`.
@mgautierfr
Copy link
Member

Rebased on master

@mgautierfr
Copy link
Member

I like the combination concept you introduce with this PR. This create a more cleaner way to create responses.

@kelson42
Copy link
Collaborator

@veloman-yunkan @mgautierfr Would be great to fix the docs/readthedocs.org:libkiwix task before merging.

@mgautierfr
Copy link
Member

I'm on it #735

@kelson42 kelson42 merged commit 49f24d1 into master Mar 28, 2022
@kelson42 kelson42 deleted the HTTP404HtmlResponse branch March 28, 2022 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants