Skip to content

Expose (kind of) InternalServer in the public API ? #740

@mgautierfr

Description

@mgautierfr

The server feature in libkiwix does several things:

  • Listen for http request (using libmicrohttpd) and convert it to a RequestContext
  • Parse the request to understand what user want.
  • Find the correct books/Archive/Searcher in the library and "resolve" the user request.
  • Build a Response
  • Convert the Response to a libmicrohttpd's response and send back the data to the user.

The first and last step is pretty tied to a http server but the other points are pretty common and it is somehow what is made in all applications.
In kiwix-desktop, we span some kind of internal server and answer to QWebEngine requests (https://github.com/kiwix/kiwix-desktop/blob/master/src/urlschemehandler.cpp)
This is probably what is done in kiwix-android or macos application.

It would be a nice thing to move all the handling in InternalServer as a first class citizen (libmicrohttpd neutral) in libkiwix API.
Then we could :

  • Unit test the "request handler" without launching a temporary server
  • Create the server on top of this "request handler" (and keep the current testing system here)
  • Use the "request handler" in kiwix-desktop

Some open questions or points to keep in mind:

  • Should we enforce a url schema or be configurable (kiwix-desktop uses a different schema than kiwix-serve)
  • I'm convinced (but you can counter-argument) that we should move to architecture where we serve "raw" content in a zim file and we add chrome/gui around using different technologies (Qt Widgets in kiwix-desktop, iframe/js in kiwix-serve, ....) With this idea, the "request handler" should handle "raw" content (I include search and co) and the "http server" should add the Chrome.

At your comments :)

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions